当前位置 : 主页 > 编程语言 > java >

单选按钮 文字背景同时改变

来源:互联网 收集:自由互联 发布时间:2022-06-23
RadioButton android:id="@+id/tank_warning_setting_2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_margin="@dimen/dp_100" android:background="@drawable/radiobutton_background" android:button="@null"
<RadioButton
android:id="@+id/tank_warning_setting_2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="@dimen/dp_100"
android:background="@drawable/radiobutton_background"
android:button="@null"
android:text="选项2"
android:textColor="@drawable/radiobutton_textcolor"
android:textSize="@dimen/sp_40" />

 


radiobutton_background

<selector xmlns:android="http://schemas.android.com/apk/res/android">

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

<item android:drawable="@drawable/radiobutton_background_checked" android:state_checked="true" />

</selector>

 


radiobutton_background_unchecked

<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<!-- 背景填充 -->
<solid android:color="@color/white" />
<!-- 圆角 -->
<corners android:radius="5dp" />
<stroke
android:width="5dp"
android:color="@color/color_text_gray" /><!-- 描边,边框宽度、颜色 -->

</shape>


radiobutton_background_checked

<shape xmlns:android="http://schemas.android.com/apk/res/android"

android:shape="rectangle">

<!-- 填充 -->
<solid android:color="#f59a23" />
<!-- 圆角 -->
<corners android:radius="5dp" />
<stroke
android:width="5dp"
android:color="@color/color_text_gray" /><!-- 描边,边框宽度、颜色 -->

</shape>


radiobutton_textcolor

<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="@color/color_text_gray" android:state_checked="false" />
<item android:color="@color/white" android:state_checked="true" />

</selector>

单选按钮 文字背景同时改变_xml



上一篇:spring boot 控制台输出登陆地址
下一篇:没有了
网友评论