> On Oct 4, 8:40 pm, "Mark Murphy" <mmur...@commonsware.com> wrote:
>> > I have a question about setting thebackgroundcolorfor buttons.
>> > When I am using btn.setBackgroundColor(Color.RED), the entire button
>> > turns into a red rectangle.
>>
>> Correct.
>>
>> > Is there actually a workaround to achieve this?
>>
>> What is "this"?
>
>
>
> "this" refers to the intention to set the button with a Red background
> color.
> I actually meant to ask if there are any other ways to set the button
> with a Red background color.
>
> :)

Option #1: Use a red color, as you did there. Downside: your button will
appear to be no longer focusable or clickable, since the different button
UI states for those events are actually part of the button background.

Option #2: Create a StateListDrawable, perhaps through a <selector> XML
file in res/drawable/. Clone the XML from the XML used by Android for
buttons by default, and replace whichever states you want with a solid red
color, or a red .9.png file, or something.

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com
Android App Developer Books: http://commonsware.com/books.html



--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to