Also tried this:

                StateListDrawable sd = new StateListDrawable();
                int stateFocused = android.R.attr.state_focused;
                int statePressed = android.R.attr.state_pressed;
                Drawable norm = this.getResources().getDrawable
(android.R.drawable.btn_default);
                sd.addState(new int[]{statePressed}, norm);
                sd.addState(new int[]{stateFocused}, norm);
                norm.mutate().setColorFilter(Color.parseColor(this.getString
(R.color.button_blue)), Mode.MULTIPLY);
                sd.addState(new int[]{-stateFocused, -statePressed}, norm);

                myButton.setBackgroundDrawable(sd);

Which....seems like it would make sense.  But i get nullpointer
exception because turns out I can't mutate an android.R.drawable...

Any ideas?? Help!!


On Feb 2, 4:23 pm, RLo <[email protected]> wrote:
> 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 tried:
>
> myButton.getBackground().getCurrent().setColorFilter(Color.parseColor
> (this.getString(R.color.button_blue)), Mode.MULTIPLY);
>
> But this does no coloring at all.  I'm not sure how else to do this.
>
> Any help please?  Thanks very much!!

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to