このようなチェックボックスを作りたい
どうすれば自分で実装できますか?
次のようなセレクター xml ファイルを作成します。この画像を切り取り、yellow_show という名前で保存し、別の画像をチェックマークなしでこのボックスの正方形のみを切り取り、その画像を yellow_hide として保存する必要があります。
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_checked="true" android:drawable="@drawable/yellow_hide" />
<item android:state_checked="false" android:drawable="@drawable/yellow_show" />
</selector>
この xml ファイルを res\drawables\ フォルダーに保存します。次に、レイアウト ファイル内で、次のように checkBox に適用します。
<CheckBox
android:text="Custom CheckBox"
android:button="@drawable/checkbox_selector"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>