3 回答

TA貢獻(xiàn)1963條經(jīng)驗(yàn) 獲得超6個(gè)贊
如果您minSdkVersion的21+使用android:buttonTint屬性更新復(fù)選框的顏色:
<CheckBox
...
android:buttonTint="@color/tint_color" />
在使用AppCompat庫并支持21以下Android版本的項(xiàng)目中,您可以使用該buttonTint屬性的compat版本:
<CheckBox
...
app:buttonTint="@color/tint_color" />
在這種情況下,如果你想要子類,CheckBox請(qǐng)不要忘記使用AppCompatCheckBox。
以前的答案:
您可以CheckBox使用android:button="@drawable/your_check_drawable"屬性更改s drawable 。

TA貢獻(xiàn)1895條經(jīng)驗(yàn) 獲得超3個(gè)贊
您可以直接在XML中更改顏色。使用buttonTint的盒:(如API等級(jí)23)
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:buttonTint="@color/CHECK_COLOR" />
您也可以使用appCompatCheckbox v7較舊的API級(jí)別執(zhí)行此操作:
<android.support.v7.widget.AppCompatCheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:buttonTint="@color/COLOR_HERE" />

TA貢獻(xiàn)1111條經(jīng)驗(yàn) 獲得超0個(gè)贊
你可以設(shè)置復(fù)選框的android主題,以獲得你在styles.xml中添加的顏色:
<style name="checkBoxStyle" parent="Base.Theme.AppCompat">
<item name="colorAccent">CHECKEDHIGHLIGHTCOLOR</item>
<item name="android:textColorSecondary">UNCHECKEDCOLOR</item>
</style>
然后在你的布局文件中:
<CheckBox
android:theme="@style/checkBoxStyle"
android:id="@+id/chooseItemCheckBox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
不像使用android:buttonTint="@color/CHECK_COLOR"這種方法在Api 23下工作
- 3 回答
- 0 關(guān)注
- 3096 瀏覽
添加回答
舉報(bào)