Coloring Default Buttons - color filter only on unfocused st

Put problem concerning Views, Layouts and other XML-Resources (like AndroidManifest) here.

Coloring Default Buttons - color filter only on unfocused st

Postby leechadeh » Thu Feb 04, 2010 1:05 am

Hi All,

I want to buttons of different colors, but I want to do so while using the default button background resource in order to preserve the onfocus and onclick states. This is because I want to use the default highlight color of the OS for my app, which is NOT always orange (HTC Sense makes it green).

I found that adding a color filter to the button's background drawable works great (in this case, blue):

myButton.getBackground().setColorFilter(Color.parseColor(this.getString (R.color.button_blue)), Mode.MULTIPLY);

BUT, when the button is focused or clicked, it turns a nasty orange_blue because it mixes the color filter with the orange of the background drawable.

I want to ONLY set this color filter for the unfocused/unclicked nine- patch drawable within the default button's statelistdrawable. I'm not sure how else to do this.

I see a similar solution here: http://stackoverflow.com/questions/2065 ... cting-fo...

but I have some concerns with that solution, mainly what if the OS changes the graphic of the default button? Since the normal unfocused/ unpressed graphic is now hardcoded into the app, it would break the flow.

Maybe can someone comment on whether it would be good or bad practice to hardcode the default graphic into the app? What are the chances of the OS completely changing the graphic?

Any help please? Thanks very much!!
leechadeh
Once Poster
Once Poster
 
Posts: 1
Joined: Thu Feb 04, 2010 12:24 am

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: No registered users and 4 guests