找到很多关于如何更改 1. 复选框颜色、复选框颜色等的问题/答案,但没有关于增加复选框边框(方形边框)的问题/答案。
下面是我的复选框 xml 代码
<CheckBox
android:id="@+id/mChkAgree"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_margin="10dp"
android:buttonTint="@color/black"
android:scaleX="1.70"
android:scaleY="1.70"
android:text="@string/agree_text"
android:textColor="@color/black"
android:textSize="14sp" />
现在复选框边框几乎不可见
那么如何增加方形复选框的边框(宽度)呢?
我也不想为复选框使用图像,所以可以不使用自定义图像吗?
最佳答案
根据这篇文章:http://www.techrepublic.com/blog/software-engineer/create-a-custom-checkbox-in-your-android-app/
增加正方形边框的最佳方法是使用带有自定义 android:drawable 标签的复选框。
自定义可绘制对象示例(放入/res/xml 文件夹)
<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<stroke android:width="4px"/>
<size android:height="20dp" android:width="20dp"/>
</shape>
还有……
<CheckBox
android:id="@+id/mChkAgree"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_margin="10dp"
android:buttonTint="@color/black"
android:scaleX="1.70"
android:scaleY="1.70"
android:text="@string/agree_text"
android:textColor="@color/black"
android:textSize="14sp"
android:drawable="@xml/custom_checkbox />
关于android - 如何在不使用android中的图像的情况下增加复选框边框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38721853/