2

私はAppCompatRadioButtonを使用していると私はそのために私のカスタム描画可能を使用したいと私は以下のコードを経由して、これを達成したが、そのは、API> = 21API <21のアンドロイドのラジオボタンドロワブルを変更できますか?

<android.support.v7.widget.AppCompatRadioButton 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content"/> 

selector_custom_radio_buttons.xml

のためにのみ働きます
<?xml version="1.0" encoding="utf-8"?> 
<selector xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto"> 
<item android:drawable="@drawable/ic_done_single" android:state_checked="false" /> 
<item android:drawable="@drawable/ic_done_all" android:state_checked="true" /> 
</selector> 

し、私は活動をテーマにスタイルを経由してラジオボタンセレクタを設定

のstyles.xml

<!-- Base application theme. --> 
<style name="ThemeNewsFeed" parent="Theme.AppCompat.Light.NoActionBar"> 
    <!-- Customize your theme here. --> 
    <item name="colorPrimary">@color/colorPrimary</item> 
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item> 
    <item name="colorAccent">@color/colorAccent</item> 
    <item name="android:radioButtonStyle">@style/MyRadioButtonStyle</item> 
</style> 

<style name="MyRadioButtonStyle"> 
    <item name="android:button">@drawable/selector_custom_radio_buttons</item> 
</style> 

、ここでは、AndroidManifest.xmlを

<activity android:name=".social.NewsFeedActivity" 
     android:theme="@style/ThemeNewsFeed"> 
     <intent-filter> 
      <action android:name="android.intent.action.MAIN" /> 
      <category android:name="android.intent.category.LAUNCHER" /> 
     </intent-filter> 

    </activity> 

での活動です。注:問題は私のカスタム描画可能である少ないし、API 21および大きいではなく、APIにも取り組んでいます21、デフォルトのラジオボタンの描画可能を示します。では、APIを低くするためにはどうすればよいですか?

答えて

1

ただ、活動のテーマからあなたAppCompatRadioButtonスタイルを削除し、

<android.support.v7.widget.AppCompatRadioButton 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    style="@style/MyRadioButtonStyle""/> 

とStyle.xml

<style name="MyRadioButtonStyle" parent="@android:style/Widget.CompoundButton.RadioButton"> 
     <item name="android:button">@drawable/selector_custom_radio_buttons</item> 
    </style> 
で以下のようにAppCompatRadioButtonのXMLコードに直接設定
関連する問題