[英]Radiobutton in a RadioGroup not visible after target API 22
我使用的RadioGroup與RadioButtons一起使用,而我的目標SDK是Android 4.4.2。 當我定位Android 5.01時,它僅適用於Android 5.01。 在Android 4.4.2中,以前可以使用,但現在當選中單選按鈕時,它不可見。 這些操作仍然有效,但是未選中或取消選中單選按鈕。 現在,它對任何一個都不起作用。
以下是我的單選按鈕。 我的背景色是黑色。
<RadioButton
android:id="@+id/radio_easy"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/easy"
style="@style/RadioButtonText" />
<RadioButton
android:id="@+id/radio_medium"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/medium"
style="@style/RadioButtonText"/>
<RadioButton
android:id="@+id/radio_hard"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/hard"
style="@style/RadioButtonText" />
</RadioGroup>
這是我的AppTheme:
<style name="AppBaseTheme" parent="Theme.AppCompat.Light">
<!--
Theme customizations available in newer API levels can go in
res/values-vXX/styles.xml, while customizations related to
backward-compatibility can go here.
-->
</style>
<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
</style>
您可以對radioButton使用自定義設計。
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/check_red" android:state_checked="true" android:state_window_focused="false"/>
<item android:drawable="@drawable/check_gray" android:state_checked="false" android:state_window_focused="false"/>
<item android:drawable="@drawable/check_red" android:state_checked="true" android:state_pressed="true"/>
<item android:drawable="@drawable/check_gray" android:state_checked="false" android:state_pressed="true"/>
<item android:drawable="@drawable/check_red" android:state_checked="true" android:state_focused="true"/>
<item android:drawable="@drawable/check_gray" android:state_checked="false" android:state_focused="true"/>
<item android:drawable="@drawable/check_gray" android:state_checked="false"/>
<item android:drawable="@drawable/check_red" android:state_checked="true"/>
我不知道你是否還在
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.