亚洲免费在线-亚洲免费在线播放-亚洲免费在线观看-亚洲免费在线观看视频-亚洲免费在线看-亚洲免费在线视频

自定義RadioButton樣式1

系統 1769 0


主要是布局:
    
<?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>

  

state_btn.xml:
    
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android"> 
       <item android:state_window_focused="false"      
             android:drawable="@drawable/bg_btn"/>  
       <item android:state_focused="true" android:state_pressed="true"         
             android:drawable="@drawable/bg_btn_selected" />  
       <item android:state_focused="false" android:state_pressed="true"    
             android:drawable="@drawable/bg_btn_selected" />  
</selector>

  


上面的寫法有點拖沓,采用style可能會更簡單:
    
<?xml version="1.0" encoding="utf-8"?> 
<resources> 
<style name="CustomTheme" parent="android:Theme"> 
   <item name="android:radioButtonStyle">@style/RadioButton</item> 
</style> 
<style name="RadioButton" parent="@android:style/Widget.CompoundButton.RadioButton"> 
   <item name="android:button">@drawable/radio</item> 
</style> 
</resources> 

  

radio.xml:
    
<?xml version="1.0" encoding="utf-8"?> 
<selector xmlns:android="http://schemas.android.com/apk/res/android"> 
    <item android:state_checked="true" android:state_window_focused="false" 
        android:drawable="@drawable/radio_hover" /> 
    <item android:state_checked="false" android:state_window_focused="false" 
        android:drawable="@drawable/radio_normal" /> 
    <item android:state_checked="true" android:state_pressed="true" 
        android:drawable="@drawable/radio_active" /> 
    <item android:state_checked="false" android:state_pressed="true" 
        android:drawable="@drawable/radio_active" /> 
    <item android:state_checked="true" android:state_focused="true" 
        android:drawable="@drawable/radio_hover" /> 
    <item android:state_checked="false" android:state_focused="true" 
        android:drawable="@drawable/radio_normal_off" /> 
    <item android:state_checked="false" android:drawable="@drawable/radio_normal" /> 
    <item android:state_checked="true" android:drawable="@drawable/radio_hover" /> 
</selector> 

  


實現分斷Button,模仿MIUI設置頁面頂部Button
http://blog.csdn.net/hudan2714/article/details/8228173

自定義RadioButton樣式1


更多文章、技術交流、商務合作、聯系博主

微信掃碼或搜索:z360901061

微信掃一掃加我為好友

QQ號聯系: 360901061

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。

【本文對您有幫助就好】

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描上面二維碼支持博主2元、5元、10元、自定義金額等您想捐的金額吧,站長會非常 感謝您的哦!!!

發表我的評論
最新評論 總共0條評論
主站蜘蛛池模板: 久久精品人人做人人看最新章 | 久久久久久久国产a∨ | 日本免费中文字幕在线看 | 日日干日日操 | 国产一级精品高清一级毛片 | 国产毛片久久精品 | 私人免费影院入口 | 青草91| 欧美精选在线 | 99热这里只有精品在线播放 | 男人爱看的网站 | 亚洲性生活视频 | 一级特黄色大片 | 久久久久国产成人精品 | 欧美日韩日本国产 | 国产成人在线免费视频 | 青青爽国产手机在线观看免费 | 日韩黄色网页 | 亚洲夜色综合久久 | 日日操网站 | 成人网18免费网站 | 成人小视频免费在线观看 | 欧美成人精品欧美一级乱黄 | 婷婷激情在线视频 | 国产午夜精品一区二区三区嫩草 | 欧美曰批人成在线观看 | 精品日韩在线视频一区二区三区 | 中文字幕亚洲精品日韩精品 | 国产亚洲人成a在线v网站 | 一级aa 毛片高清免费看 | α片毛片 | 日韩香蕉网 | 欧美黑人喷潮水xxxx | 色综合一本到久久亚洲91 | 久久久久综合国产 | 九九久久精品国产 | 日日摸夜夜摸狠狠摸日日碰夜夜做 | 国产日韩久久久精品影院首页 | 久久综合九色综合97欧美 | 夜夜春夜夜爽久久 | 老师粗又长好猛好爽视频 |