views:

273

answers:

2

Hi,

I want to use a Button in my android app but I want to customize how it looks. However, I want the highlight and selected colors of the button to be the same as the default colors (i.e. the dark and light orange gradients, or whatever the theme color supplies).

Is there anyway to get the default highlight/selected drawables and to use that as the fill for my buttons on the selected and highlighted states?

Thanks!

+1  A: 

You are asking for two different things, do you want the drawables or the colorcode?

Anyway, you can find the name of the drawables here: http://androiddrawableexplorer.appspot.com/ I don't know if you can use them directly from your app or if you have to save them to your drawables folder first, but you can find them in your sdk. If you want the colorcodes, use gimp to extract them from the pictures.

softarn
I guess I want the color code, with which I can then create my own drawable? Basically I want to ensure that my highlight/selected color are always consistent on each device. So I don't want to hardcode in the orange color since this may change in the future and some devices use a different color. Rather I would like to grab the colorcode programmatically.
Wise Shepherd
Since android is using drawables and not colorcodes for their buttons you wont be able to get the colorcode in any programmatically reasonable way. Well I'm sure that there is a way somehow but I don't think that it's worth it.
softarn
ok.. gotcha.. so I just need to know how to access the drawable that contains the default select/highlight colors....
Wise Shepherd
You can find one xml and one java example in the link I posted.
softarn
A: 

Selectors are what you're looking for. Google around for tutorials. Here's one.

I Suppose you can find the Default Selector in the Android Source Code.

st0le
Is there any way to grab the default selector color programmatically?
Wise Shepherd