custom ur own radio button style

来源:互联网 发布:网络回拨电话合法吗 编辑:程序博客网 时间:2024/05/07 07:57

1.

在res/drawable下创建radiobutton.xml:

<selector xmlns:android="http://schemas.android.com/apk/res/android"> 
    <item 
     android:state_enabled="true" 
          android:state_checked="true"
          android:drawable="@drawable/check"/> 
    <item              
          android:state_enabled="true"     
          android:state_checked="false"
          android:drawable="@drawable/checknull"/> 
          
    <item 
     android:state_enabled="false" 
          android:state_checked="true"
          android:drawable="@drawable/check_disable"/>

    <item 
     android:state_enabled="false" 
          android:state_checked="false"
          android:drawable="@drawable/checknull_disable"/>

</selector>


2.

创建4个图片:

check.png check_disable.png checknull.png checknull_disable.png


3.

添加 android:button = "@drawable/radiobutton"标签:

            <RadioButton 
                android:id="@+id/MainAfInfinityRadioButtonId"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight = "1"
                android:textColor="#FFFFFF"
                android:textStyle="bold"
                android:text="@string/MainAfInfinityText"
                android:onClick="onRadioButtonClicked"
                android:button = "@drawable/radiobutton"
                /> 



0 0
原创粉丝点击