Is ImageView opacity changeable?

nfordbscndrd

Well-Known Member
Licensed User
Longtime User
In a card game where a player must follow suit, I would like to darken the cards in the other suits. Is it possible to change the opacity of an ImageView? I don't want to go to the trouble of creating a second set of 52 darkened card images unless that's the only alternative.
 

Bob Katayama

Member
Licensed User
Longtime User
In a card game where a player must follow suit, I would like to darken the cards in the other suits. Is it possible to change the opacity of an ImageView? I don't want to go to the trouble of creating a second set of 52 darkened card images unless that's the only alternative.

The IMAGEVIEW supports a different background image therefore all you do is create a light and dark image background with the light being the default. Then switch all the cards that need a dark background with the dark one. This means each card displayed would use a separate imageview object.

Just my 2 cents.

Bob
 
Last edited:
Upvote 0

nfordbscndrd

Well-Known Member
Licensed User
Longtime User
The IMAGEVIEW supports a different background image therefore all you do is create a light and dark image background with the light being the default. Then switch all the cards that need a dark background with the dark one. This means each card displayed would use a separate imageview object.

I'm not sure that I understand, but it sounds like I would have to create another set of 52 darkened card images, which is what I was trying to avoid.
 
Upvote 0

dlfallen

Active Member
Licensed User
Longtime User
There is often more than one way to skin a cat.

In this case, create a Label in the same width/height as the card image. Set the color to Black and the Alpha to something between 0 and 255 -- the higher the number, the darker the label. I tried a value of 100 and it looked OK (see attached image), but you might want it darker still - experiment with this value.

Probably the easiest way to implement this approach is to have a dark label for each of the card positions and manipulate the Label's visibility as required.
 

Attachments

  • DarkCard.jpg
    DarkCard.jpg
    39.9 KB · Views: 418
Upvote 0

nfordbscndrd

Well-Known Member
Licensed User
Longtime User
There is often more than one way to skin a cat.

In this case, create a Label in the same width/height as the card image. Set the color to Black and the Alpha to something between 0 and 255 -- the higher the number, the darker the label. I tried a value of 100 and it looked OK (see attached image), but you might want it darker still - experiment with this value.

Probably the easiest way to implement this approach is to have a dark label for each of the card positions and manipulate the Label's visibility as required.

That does the trick!! I had actually tried a label once, but couldn't find a way to adjust the transparency. It never dawned on me that "Alpha" meant "transparency".

I was planning on just using two labels, one for the left side of the selected suit and the other for the right side, so I'll see how that goes.

I'll be uploading "Card Game Shell" in a bit, after I get this added. This was my last hurdle. It's funny - you provided the first step (the cards) and the last step (darkening the cards).

Thanks.
 
Upvote 0

Bob Katayama

Member
Licensed User
Longtime User
I'm not sure that I understand, but it sounds like I would have to create another set of 52 darkened card images, which is what I was trying to avoid.

The background image is just the typical white space and the forground image with the transparent color would be the card suit images. Switch between the solid white image and the solid darker background image as required within the imageview.

You only still need 52 basic cards plus a white solid background image and a solid darker image.

Bob
 
Upvote 0
Top