安卓RadioButton边框圆滑怎么写
可以通过定义一个自定义的drawable来实现RadioButton边框圆滑的效果。
- 创建一个名为custom_radio_button_bg.xml的drawable文件,内容如下:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<!--设置背景颜色-->
<solid android:color="#FFFFFF" />
<!--设置边框宽度和颜色-->
<stroke
android:width="2dp"
android:color="#000000" />
<!--设置圆角半径-->
<corners android:radius="20dp" />
</shape>
- 在RadioButton控件中引用该drawable:
<RadioButton
android:id="@+id/radio_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:button="@null"
android:background="@drawable/custom_radio_button_bg"
android:text="Radio Button" />
其中,android:button="@null"表示不使用系统默认的RadioButton样式,而是使用自定义的背景样式。
这样就可以实现RadioButton边框圆滑的效果了
原文地址: https://www.cveoy.top/t/topic/hpyI 著作权归作者所有。请勿转载和采集!