Android Question Can a Label's Alpha be Changed Programatically?

Shadow&Max

Active Member
Licensed User
Longtime User
I need to change a label's opacity (Alpha) from transparent to opaque and back during execution. Is that possible???

If so, how? I can't seem to find a way to do it...
 

HotShoe

Well-Known Member
Licensed User
Longtime User
You can set its color using argb:

label1.color = colors.argb(128,0,0,144)

The first parameter id the alpha value from 0 - 255.

--- Jem
 
Upvote 0

Shadow&Max

Active Member
Licensed User
Longtime User
Thanks Jem... I've been working with stock colors, that I assign on the run, and have no idea how to get the RGB value of a stock color... I know the Alpha setting, but don't know the RGB value... Is there a way to extract that RGB from a standard color?
 
Upvote 0

HotShoe

Well-Known Member
Licensed User
Longtime User
I don't know the stock constant values. They "might" be listed in a VB book or on google. I generally use the designer to tell me. I set a color, save the designer, and then close the designer. When you reopen the designer and lod that layout, the color is in rgb format. It would be nice to have a list of the color constants.

--- Jem
 
Upvote 0

Shadow&Max

Active Member
Licensed User
Longtime User
Thanks again Jem... The problem is that I'm letting the user select a background color from the ColorPicker dialog, and I don't know what it'll be... I've got to somehow get that value, or create a new color picker dialog of my own so I actually get the RGB values...

BTW, that's no ordinary bunny!
 
Upvote 0

Shadow&Max

Active Member
Licensed User
Longtime User
I may just be able to set it t Colors.ARGB(0,0,0,0) because if it's transparent, the color doesn't matter...

Thanks again!
 
Upvote 0

HotShoe

Well-Known Member
Licensed User
Longtime User
I see. I generally just use the colordialog from the dialogs library and let the user mix their own colors. Not as easy for the user, but much easier for me since it gives the rgb values. :)

--- Jem
 
Upvote 0

Shadow&Max

Active Member
Licensed User
Longtime User
Hi again... Well, setting it to (0,0,0,0) worked...

Which dialog is that? The only one I found is:

(clrP is a ColorPicker)

clrP.Show("Choose Color:","OK","","Cancel",Null)

I'd prefer the fullblown color dialog!
 
Upvote 0

Shadow&Max

Active Member
Licensed User
Longtime User
Thanks Bud... Somehow I missed that... Will play with that a bit now! Looks big though... not sure if it'll fit in landscape mode, but will try.

Thanks again!!!
 
Upvote 0

Shadow&Max

Active Member
Licensed User
Longtime User
Tried it... Fine in portrait, 1 color bar cut off/missing in landscape. Maybe that's why I didn't use it at first... been working on this app for quite a while, and that was early on... I may have to make my own!
 
Upvote 0

mangojack

Well-Known Member
Licensed User
Longtime User
this might be of use .. RGB and hex color values .. its in Excel format.
 

Attachments

  • Android Color Chart.zip
    17.2 KB · Views: 216
Upvote 0

Shadow&Max

Active Member
Licensed User
Longtime User
Very, very helpfiul... Thanks MJ... great resource!
 
Upvote 0
Top