自定義復選框圖像android是否有一種簡單的方法可以將自定義圖像用于復選框?我想復制gmail的“已加星標”行為。所以我希望有一個復選框,當選中時,它是一個填充星號。當未經檢查的是一顆空星。我是否必須使用imageview并自己做我自己的邏輯?
3 回答
holdtom
TA貢獻1805條經驗 獲得超10個贊
將btn_check.xml從android-sdk / platforms / android - #/ data / res / drawable復制到項目的drawable文件夾,并將“on”和“off”圖像狀態更改為自定義圖像。
然后你的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" />
如果你想使用不同的默認android圖標,你可以使用 android:button="@android:drawable/..."
- 3 回答
- 0 關注
- 540 瀏覽
添加回答
舉報
0/150
提交
取消
