Android自定义复选框可绘制尺寸
对于我的自定义复选框,我使用了使用android studio创建的simple nine补丁(来自png的512x512px) 以下是用于自定义的xml复选框:Android自定义复选框可绘制尺寸,android,checkbox,Android,Checkbox,对于我的自定义复选框,我使用了使用android studio创建的simple nine补丁(来自png的512x512px) 以下是用于自定义的xml复选框: <?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:drawable="@drawable/ic_ch
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/ic_checkbox_unchecked" android:state_checked="false"/>
<item android:drawable="@drawable/ic_checkbox_checked" android:state_checked="true"/>
<item android:drawable="@drawable/ic_checkbox_unchecked"/>
</selector>
我读过很多关于这个主题的文章,但是我发现没有一篇文章涉及到支票盒的大小,因为我的新复选框的大小和可绘制的一样大。任何设置固定尺寸的尝试,例如30x30dp,都会导致可拉伸变形
那么,图像可抽件的大小应该是多少?如果可抽件的大小无关紧要,我如何将复选框的大小设置为标准和ID复选框的大小?尝试用下一个代码修复它:
android:button="@null"
android:background="@drawable/your_custom_checkbox_state.xml"
已经有了。这样,如果我将layout_width和layout_height属性设置为wrap_content,则复选框与使用的可绘制内容一样大。如果我设置了fixed属性,比如说30x30dp,那么用于checked状态的drawable就会失真。也许我不应该用九块补丁。我将尝试使用具有固定大小的通用绘图功能…尝试缩放复选框尝试过,它也会缩放绘图功能,但复选框的大小保持不变。如果不使用文本作为复选框,您可以尝试设置
android:text=”“
android:textSize=“0sp”