1

I would like to change the color of the android button in my application to be dark grey instead of light grey. I intent to keep the color of the focus/pressed the same. I just want to change the color of the button in 'normal' state to dark grey.

I have found this thread: Standard Android Button with a different color

I think the easiest way is to do this. Is that correct? But how can I make the LightingColor Filter to make it darkgrey?

button.getBackground().setColorFilter(new LightingColorFilter(0xFFFFFFFF, 0xFFAA0000));

I have tried

button.getBackground().setColorFilter(new LightingColorFilter(0xffffffff, 0xFF3A3A3A));

But all I get is a white color.

Community
  • 1
  • 1
michael
  • 106,540
  • 116
  • 246
  • 346

2 Answers2

1

That's similar to what I am doing in my TabHost tabs in XML. If you have custom buttons and graphics it can be done in Java, but it is much easier if you're able to do it in your XML.

<?xml version="1.0" encoding="UTF-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <!-- When selected, use grey -->
    <item android:drawable="@drawable/settings"
          android:state_selected="true" />
    <!-- When not selected, use white-->
    <item android:drawable="@drawable/mountain" />
</selector>
apesa
  • 12,163
  • 6
  • 38
  • 43
  • But the android's button has it own set of drawable. like it specifies the border, the padding of a button. I want my button to look exactly the same as the android default one, except it has a dark color as background. – michael Mar 30 '11 at 21:59
  • I think you;ll have to extend Button and make it your own. You can create your own drawables and use them instead of the default drawables like Button. I know I am not much help in this area, but I have seen it done on this site as I surfed answers – apesa Mar 30 '11 at 22:13
0

You could use the default light theme
Example

Iulius Curt
  • 4,984
  • 4
  • 31
  • 55