如何更改android kotlin中复选框的边框大小(厚度)?

如何更改android kotlin中复选框的边框大小(厚度)?,android,android-layout,kotlin,Android,Android Layout,Kotlin,我正在尝试将复选框缩小并更改边框的大小 我尝试过使用XML中的布局和Kotlin中的.width()或.height。也不会改变它的大小。我去看了向其他提出这些问题的人推荐的教程,但我不明白他做了什么。 有什么建议吗 mycheckbox.xml <item android:state_checked="false" android:drawable="@drawable/checkbox_off_background"/> <item

我正在尝试将复选框缩小并更改边框的大小

我尝试过使用XML中的布局和Kotlin中的
.width()
.height
。也不会改变它的大小。我去看了向其他提出这些问题的人推荐的教程,但我不明白他做了什么。 有什么建议吗

mycheckbox.xml

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

<item

        android:state_checked="true"
        android:drawable="@drawable/checkbox_on_background"/>

my_checkbox.xml

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

<item

        android:state_checked="true"
        android:drawable="@drawable/checkbox_on_background"/>


复选框\u关闭\u背景


background.xml上的复选框




试试这个,在API级别11以上

尝试使用android:scaleX和android:scaleY

谢谢,
Rhen

我猜您不能更改厚度,但可以设置“图像/可绘制”复选框。根据需要的边框厚度创建或设计可绘制,并将其设置为复选框的按钮

<CheckBox 
android:layout_width="wrap_content" 
android:layout_height="wrap_content"
android:text="checkbox" 
android:button="@drawable/checkbox_design" />


更好的例子是

厚度不能更改,但可以设置为可绘制,也可以自定义checkboxHi!请共享您的XML布局文件。谢谢如果我的答案有效,请接受并投票表决。:)你可以投票表决我的答案。
<item>
    <shape android:shape="rectangle">
        <size
                android:width="25dp"
                android:height="25dp" />
    </shape>
</item>

<item android:drawable="@android:drawable/checkbox_off_background" />
<item>
    <shape android:shape="rectangle">
        <size
                android:width="25dp"
                android:height="25dp" />
    </shape>
</item>

<item android:drawable="@android:drawable/checkbox_on_background" />
<CheckBox

    android:scaleX="0.70"
    android:scaleY="0.70"
 ...
/>
<CheckBox 
android:layout_width="wrap_content" 
android:layout_height="wrap_content"
android:text="checkbox" 
android:button="@drawable/checkbox_design" />