I am writing an application for Android 5 and above, and on one screen I need to display a group of radio with several switches, but the drawable button (xml drawable) does not appear on Android 5, but it works as expected on android 6.
This is my activity layout:
<?xml version="1.0" encoding="utf-8"?>
<RadioGroup xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:button="@drawable/radio_button_selector"
android:text="1" />
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:button="@drawable/radio_button_selector"
android:text="1" />
</RadioGroup>
radio_button_selector.xml:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_checked="true" android:drawable="@drawable/radio_button_selected" />
<item android:drawable="@drawable/radio_button_unselected" />
</selector>
And radio_button_selected.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<size
android:width="15dp"
android:height="15dp" />
<solid android:color="#643023" />
</shape>
And my activity:
public class Test extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_test);
}
}
I reproduced the problem at the emulator 21 API level and on the LG Leon 4G LTE (android 5, hdpi). The output is displayed correctly on Nexus 5 (android 6.0.1, xxhdpi) and an emulator with android 6.
All my resources are currently in the default directories.
source
share