0

私は 4.0 バージョン用の Android アプリを開発しています。すべてのチェックボックスの目盛りは黒の背景になっていますが、白が必要です。「背景」xml 属性を「白」として使用すると、すべてのチェックボックス (テキスト付き) は白になります。目盛りには白い場所だけが必要です。

4

3 に答える 3

0

私が極端に遅れているのかどうかはわかりませんが、ここに解決策があります

コードスニペット:

このセレクターは「checkbox_selector」という名前だとします

<?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/cbchk_blue"
    android:state_focused="false">
</item>
<item android:state_checked="true" 
    android:drawable="@drawable/cbchk_blue"
    android:state_focused="true">
</item>
<item android:state_checked="false" 
    android:drawable="@drawable/cbunchk_blue"
    android:state_focused="false">
</item>
<item android:state_checked="false" 
    android:drawable="@drawable/cbunchk_blue"
    android:state_focused="true">
</item>

テキスト全体ではなく、チェックボックスのみに設定するには、次のようにします。

<CheckBox
     android:layout_width="45dip"
     android:layout_height="wrap_content"
     android:layout_centerVertical="true"
     android:button="@drawable/checkbox_selector"
     android:text="@string/text_here" />
于 2014-03-05T07:02:15.897 に答える