Friday, May 14, 2010

Android custom buttons

http://stackoverflow.com/questions/1521640/standard-android-button-with-a-different-color


Put something like the following code in a file named custom_button.xml and then set background="@drawable/custom_button" in your button view:
xml version="1.0" encoding="utf-8"?>


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

android:state_pressed="true" >


android:startColor="@color/yellow1"
android:endColor="@color/yellow2"
android:angle="270" />

android:width="3dp"
color="@color/grey05" />

android:radius="3dp" />

android:left="10dp"
android:top="10dp"
android:right="10dp"
android:bottom="10dp" />



android:state_focused="true" >


android:endColor="@color/orange4"
android:startColor="@color/orange5"
android:angle="270" />

android:width="3dp"
color="@color/grey05" />

android:radius="3dp" />

android:left="10dp"
android:top="10dp"
android:right="10dp"
android:bottom="10dp" />






android:endColor="@color/blue2"
android:startColor="@color/blue25"
android:angle="270" />

android:width="3dp"
color="@color/grey05" />

android:radius="3dp" />

android:left="10dp"
android:top="10dp"
android:right="10dp"
android:bottom="10dp" />



3 comments:

Blundell said...

error: Error: No resource found that matches the given name (at 'endColor' with value '@color/
yellow2').

errr ?

Blundell said...

So I still have to have a png file in folder color/ with the color i want? :-/ lame

Blundell said...

I can just change them otu for android:startColor="#ffffd300" hex colors yayy