I have a drawable file that I put as the background for the button:
<?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:drawable="@drawable/tab_selected" android:state_pressed="true"/> <item android:drawable="@color/white" android:state_focused="true"/> <item android:drawable="@color/white"/> </selector>
I use gradient :
<?xml version="1.0" encoding="utf-8"?> <gradient xmlns:android="http://schemas.android.com/apk/res/android" > <shape xmlns:android="http://schemas.android.com/apk/res/android" > <gradient android:angle="270" android:endColor="@color/gray" android:startColor="@color/dark_gray" /> </shape> </gradient>
Without using gradient everything worked, but now, when I try to set the background for the button via setBackgroundResource(R.drawable.button2) , the application crashes with the message "Application Stopped." What did I do wrong in the gradient or somewhere else?
PS The colors are assigned correctly and the drawable file drawable without using the gradient too.