android radiogroup樣式(設定切換背景與文字顏色),androidradiogroup

來源:互聯網
上載者:User

android radiogroup樣式(設定切換背景與文字顏色),androidradiogroup

 main.xml

 1 <RadioGroup 2                 android:id="@+id/radioGroup1" 3                 android:layout_width="wrap_content" 4                 android:layout_height="36dp" 5                 android:layout_gravity="center" 6                 android:layout_weight="1" 7                 android:orientation="horizontal" > 8  9                 <RadioButton10                     android:id="@+id/radio0"11                     android:layout_width="0dp"//設0才可以與radio1平分寬度12                     android:layout_height="wrap_content"13                     android:layout_weight="1"14                     android:background="@drawable/radio_check"15                     android:button="@null"16                     android:checked="true"17                     android:gravity="center"18                     android:text="@string/title"19                     android:textColor="@drawable/radio_text_check" />20 21                 <RadioButton22                     android:id="@+id/radio1"23                     android:layout_width="0dp"24                     android:layout_height="wrap_content"25                     android:layout_weight="1"26                     android:background="@drawable/radio_check"27                     android:button="@null"28                     android:gravity="center"29                     android:text="@string/title2"30                     android:textColor="@drawable/radio_text_check" />31 32             </RadioGroup>

 

radio_text_check.xml
1 <?xml version="1.0" encoding="utf-8"?>2 <selector xmlns:android="http://schemas.android.com/apk/res/android">3 4     <item android:state_checked="true" android:color="@android:color/white"/>5     <item android:state_checked="false" android:color="@android:color/holo_blue_bright"/>6 7 </selector>

 

radio_check.xml
<?xml version="1.0" encoding="utf-8"?><selector xmlns:android="http://schemas.android.com/apk/res/android">    <item android:drawable="@drawable/image1" android:state_checked="true"/>    <item android:drawable="@drawable/image2" android:state_checked="false"/></selector>

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.