【问题标题】:how to increase checkbox border without using images in android如何在不使用android中的图像的情况下增加复选框边框
【发布时间】:2016-12-07 21:24:18
【问题描述】:

发现了很多关于如何更改 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" />

现在复选框的边框几乎看不到了

那么如何增加方形复选框的边框(宽度)?

另外我不想在复选框中使用图像,那么是否可以不使用自定义图像?

【问题讨论】:

    标签: android checkbox size width border


    【解决方案1】:

    据此贴:http://www.techrepublic.com/blog/software-engineer/create-a-custom-checkbox-in-your-android-app/

    增加正方形边框的最佳方法是使用带有自定义 android:drawable 标签的复选框。

    自定义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 />
    

    【讨论】:

    • 非常感谢,但您的解决方案以及该帖子中的解决方案都不起作用。您的解决方案没有效果,而该链接中的解决方案给出了填充黑色的正方形
    猜你喜欢
    • 1970-01-01
    • 2020-08-09
    • 1970-01-01
    • 2018-09-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-06-13
    相关资源
    最近更新 更多