I see a similar solution on stackoverflow: http://stackoverflow.com/questions/2065430/fixed-android-detecting-focus-pressed-color/2189757#2189757
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? Thanks! On Feb 2, 4:57 pm, RLo <leecha...@gmail.com> wrote: > 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 <leecha...@gmail.com> 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 android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en