自定義復(fù)選框圖像android是否有一種簡(jiǎn)單的方法可以將自定義圖像用于復(fù)選框?我想復(fù)制gmail的“已加星標(biāo)”行為。所以我希望有一個(gè)復(fù)選框,當(dāng)選中時(shí),它是一個(gè)填充星號(hào)。當(dāng)未經(jīng)檢查的是一顆空星。我是否必須使用imageview并自己做我自己的邏輯?
3 回答

30秒到達(dá)戰(zhàn)場(chǎng)
TA貢獻(xiàn)1828條經(jīng)驗(yàn) 獲得超6個(gè)贊

holdtom
TA貢獻(xiàn)1805條經(jīng)驗(yàn) 獲得超10個(gè)贊
將btn_check.xml從android-sdk / platforms / android - #/ data / res / drawable復(fù)制到項(xiàng)目的drawable文件夾,并將“on”和“off”圖像狀態(tài)更改為自定義圖像。
然后你的xml將需要 android:button="@drawable/btn_check"
<CheckBox android:button="@drawable/btn_check" android:layout_width="wrap_content" android:layout_height="wrap_content" android:checked="true" />
如果你想使用不同的默認(rèn)android圖標(biāo),你可以使用 android:button="@android:drawable/..."
- 3 回答
- 0 關(guān)注
- 526 瀏覽
添加回答
舉報(bào)
0/150
提交
取消