2

I have to create a custom compound button bar control in Android like the one here. To create a button bar like this, I am thinking of extending a LinearLayout and add my buttons to it. The buttons have a black background but with a gradient fill; I am not keen on using PNGs since the color of the buttons can change at runtime.

How can I get similar effect in Android?

Thanks.

vijay
  • 23
  • 1
  • 3

1 Answers1

4

u have to use imageview as button.

set two image view you can change color the button

use xml file to src of that imageview like

<?xml version="1.0" encoding="UTF-8"?>

<selector xmlns:android="http://schemas.android.com/apk/res/android">

<item android:state_pressed="false"
    android:drawable="@drawable/back_normal" />

<item android:state_pressed="true"
    android:drawable="@drawable/back_pressed" />

</selector>

for gredient style.

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<gradient android:angle="90" android:startColor="#663300"
    android:centerColor="#330000"
    android:endColor="#330000"/>
</shape>

thats it.

Praveen
  • 90,477
  • 74
  • 177
  • 219