仕事でチェックボックスの画像をカスタマイズする必要があります。最終的にhow-to-change-default-images-of-checkboxで解決策を見つけました。「android:button」属性を使用するとうまく機能しますが、別の問題が残りました。 「android:button」属性が適用され、チェックとチェックを外しにくくなります。
以下は、チェックボックスのセレクターです。
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/gn_checkbox_checked" android:state_checked="true"/>
<item android:drawable="@drawable/gn_checkbox_normal" android:state_checked="false"/>
<item android:drawable="@drawable/gn_checkbox_normal"/>
</selector>
そして、このセレクターを使用するチェックボックス:
<CheckBox
android:id="@+id/timeline_check"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:button="@drawable/checkbox"
android:layout_marginRight="3dp" />
注: 「android:button」属性がないと、チェックボックスのチェックとチェック解除が簡単になります。この問題を解決するエレガントな方法はありますか? どうもありがとう。