I had a button with a drawable selector set as its background.
button_sign_in_background.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/button_sign_in_background_selected" android:state_focused="true" />
<item android:drawable="@drawable/button_sign_in_background_selected" android:state_pressed="true" />
<item android:drawable="@drawable/button_sign_in_background_selected" android:state_selected="true" />
<item android:drawable="@drawable/button_sign_in_background_normal" />
</selector>
button_sign_in_background_normal.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle"
android:visible="true">
<corners android:radius="@dimen/abc_control_corner_material" />
<solid android:color="@color/color_primary" />
</shape>
button_sign_background_selected.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners android:radius="@dimen/abc_control_corner_material" />
<solid android:color="@color/color_primary_dark" />
</shape>
I tested in two different devices, one with API 21 and another is API 10. The background button_sign_in_background.xml
can't show in API 10, but it works in API 21 device.
If I use color directly in button_sign_in_background.xml
as following, both devices work. But this is not the effect I need, what I want is a small radius corner surround the button.
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@color/color_primary_dark" android:state_focused="true" />
<item android:drawable="@color/color_primary_dark" android:state_pressed="true" />
<item android:drawable="@color/color_primary_dark" android:state_selected="true" />
<item android:drawable="@color/color_primary" />
</selector>
Is that a compatibility problem in old android device?
How can i solve it? Any kind of comment and answer are welcomed.