日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

RadioButton 自定义控件

發布時間:2025/5/22 编程问答 26 豆豆
生活随笔 收集整理的這篇文章主要介紹了 RadioButton 自定义控件 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

?

在res/drawable新建radiobutton.xml(本案例為video——evaluate.xml)如下

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

?

布局文件:

<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="match_parent"android:layout_height="match_parent"android:background="#f3f3f3"android:orientation="vertical" ><include layout="@layout/titlebar" /><TextViewandroid:layout_width="match_parent"android:layout_height="wrap_content"android:paddingTop="15dp" android:paddingLeft="10dp"android:text="對此次服務滿意嗎?"android:textColor="#2e2e2e"android:textSize="@dimen/text_size18sp" /><Viewandroid:layout_width="fill_parent"android:layout_height="0.8dp"android:layout_marginTop="10dp"android:background="@color/expertlist_divider_color" /><RadioGroupandroid:id="@+id/evaluate_rg"android:layout_width="fill_parent"android:layout_height="wrap_content"android:orientation="vertical"android:background="@color/white"android:paddingBottom="8dp"android:paddingTop="8dp" > <RadioButtonandroid:id="@+id/radio1"android:layout_width="fill_parent"android:layout_height="wrap_content"android:layout_centerVertical="true"android:layout_marginLeft="10dp"android:paddingBottom="10dp"android:checked="true"android:text="非常滿意"android:textSize="18sp"android:button="@drawable/video_evaluate" /><Viewandroid:layout_width="fill_parent"android:layout_height="0.3dp"android:layout_marginTop="10dp"android:background="@color/expertlist_divider_color" /><RadioButtonandroid:id="@+id/radio2"android:layout_width="fill_parent"android:layout_height="wrap_content"android:layout_centerVertical="true"android:layout_marginLeft="10dp"android:text="滿意"android:textSize="18sp"android:button="@drawable/video_evaluate" /><Viewandroid:layout_width="fill_parent"android:layout_height="0.3dp"android:layout_marginTop="10dp"android:background="@color/expertlist_divider_color" /><RadioButtonandroid:id="@+id/radio3"android:layout_width="fill_parent"android:layout_height="wrap_content"android:layout_marginLeft="10dp"android:text="一般"android:textSize="18sp"android:button="@drawable/video_evaluate" /><Viewandroid:layout_width="fill_parent"android:layout_height="0.3dp"android:layout_marginTop="10dp"android:background="@color/expertlist_divider_color" /><RadioButtonandroid:id="@+id/radio4"android:layout_width="fill_parent"android:layout_height="wrap_content"android:layout_marginLeft="10dp"android:text="不滿意"android:textSize="18sp"android:button="@drawable/video_evaluate" /><Viewandroid:layout_width="fill_parent"android:layout_height="0.3dp"android:layout_marginTop="10dp"android:background="@color/expertlist_divider_color" /><RadioButtonandroid:id="@+id/radio5"android:layout_width="fill_parent"android:layout_height="wrap_content"android:layout_marginLeft="10dp"android:text="非常不滿意"android:textSize="18sp"android:button="@drawable/video_evaluate" /><Viewandroid:layout_width="fill_parent"android:layout_height="0.3dp"android:layout_marginTop="10dp"android:background="@color/expertlist_divider_color" /></RadioGroup><Buttonandroid:id="@+id/bt_evaluate"android:layout_width="match_parent"android:layout_height="wrap_content"android:layout_gravity="center"android:layout_marginTop="30dp"android:layout_marginLeft="10dp"android:layout_marginRight="10dp"android:background="@drawable/expert_yuye_bg_selector"android:text="提交"android:textColor="@color/white"android:textSize="@dimen/text_size16sp" /></LinearLayout>

?

效果,自己可以優化一下再:

?

轉載于:https://www.cnblogs.com/McCa/p/4522792.html

總結

以上是生活随笔為你收集整理的RadioButton 自定义控件的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。