Har*_*der 0 java checkbox android bitmap
我更改了Android 2.3.4复选框的位图,并希望设置位图的大小以缩放它们.我改变了这样的复选框:
<CheckBox
android:id="@+id/cb1"
android:button="@drawable/checkbox"
android:layout_alignParentLeft="true"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Sort: 1" />
Run Code Online (Sandbox Code Playgroud)
与匹配的xml drawable
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_checked="true" android:state_focused="true" android:drawable="@drawable/checkbox_on_background_focus_yellow"/>
<item android:state_checked="false" android:state_focused="true" android:drawable="@drawable/checkbox_off_background_focus_yellow"/>
<item android:state_checked="false" android:drawable="@drawable/checkbox_off_background" />
<item android:state_checked="true" android:drawable="@drawable/checkbox_on_background" />
</selector>
Run Code Online (Sandbox Code Playgroud)
如何设置dip/dp值来更改复选框位图的大小?
Tom*_*map 12
实际上你可以把图像设置为复选框的大小就可以了
android:button="@null"
android:background="@drawable/checkbox" <!-- your custom selector -->
Run Code Online (Sandbox Code Playgroud)
这样,您的自定义复选框图像(在两种状态下,已选中和未选中)将始终适合您的复选框的大小.