Android自定義RadioButton樣式源碼下載:
RedHat KVM內核級虛擬化技術課程PPT下載地址:
免費下載地址在 http://linux.linuxidc.com/
用戶名與密碼都是www.linuxidc.com
具體下載目錄在 /pub/Android源碼集錦/2011年/11月/Android開發教程:自定義RadioButton樣式/
主要是布局:
- <?xml version="1.0" encoding="utf-8"?>
- <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:orientation="vertical"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- >
- <RadioGroup android:gravity="center"
- android:layout_gravity="bottom"
- android:orientation="horizontal"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content" >
- <RadioButton
- android:id="@+id/btn_0"
- android:textSize="17.0sp"
- android:textColor="@android:color/black"
- android:text="搜索微博"
- android:layout_weight="1"
- android:button="@null"
- android:checked="true"
- android:drawableLeft="@drawable/state_radio"
- android:background="@drawable/state_btn"
- android:gravity="center_vertical"
- >
- </RadioButton>
- <RadioButton
- android:id="@+id/btn_1"
- android:textSize="17.0sp"
- android:textColor="@android:color/black"
- android:text="搜索用戶"
- android:layout_weight="1"
- android:button="@null"
- android:drawableLeft="@drawable/state_radio"
- android:background="@drawable/state_btn"
- android:gravity="center_vertical"
- >
- </RadioButton>
- </RadioGroup>
- </LinearLayout>
其中state_radio.xml
- <?xml version="1.0" encoding="utf-8"?>
- <selector
- xmlns:android="http://schemas.android.com/apk/res/android"
- >
- <item
- android:state_focused="false"
- android:state_checked="false"
- android:state_pressed="false"
- android:drawable="@drawable/bg_radio"
- >
- </item>
- <item
- android:state_focused="false"
- android:state_checked="true"
- android:state_pressed="false"
- android:drawable="@drawable/bg_radio_selected"
- >
- </item>
- <item
- android:state_focused="true"
- android:state_checked="false"
- android:state_pressed="false"
- android:drawable="@drawable/bg_radio_onfocus"
- >
- </item>
- <item
- android:state_focused="true"
- android:state_checked="true"
- android:state_pressed="false"
- android:drawable="@drawable/bg_radio_onfocus_selected"
- >
- </item>
- </selector>