android開發(fā)教程之自定義控件checkbox的樣式示例
主界面xml文件
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:button="@drawable/check_selector"
android:checked="true" />
</RelativeLayout>
/res/drawable-hdpi/check_selector.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/checkok" android:state_checked="true"></item>
<item android:drawable="@drawable/checkno" android:state_checked="false"></item>
</selector>
P.S:重點(diǎn): android:button="@drawable/check_selector"
check_selector.xml中的checkok為CheckBox選中狀態(tài)的圖片,checkno為CheckBox未選中狀態(tài)的圖片.
相關(guān)文章
Android ViewPager實(shí)現(xiàn)每隔兩秒自動(dòng)切換圖片功能
圖片來回自動(dòng)切換,設(shè)計(jì)非常人性化,那么圖片自動(dòng)切換功能基于代碼如何實(shí)現(xiàn)的呢?下面小編給大家?guī)砹薃ndroid ViewPager實(shí)現(xiàn)每隔兩秒自動(dòng)切換圖片功能,感興趣的朋友一起看看吧2021-10-10使用Kotlin實(shí)現(xiàn)文字漸變TextView的代碼
這篇文章主要介紹了使用Kotlin實(shí)現(xiàn)文字漸變TextView的代碼,本文通過實(shí)例代碼給大家介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2020-04-04Android編程實(shí)現(xiàn)擦除Bitmap中某一塊的方法
這篇文章主要介紹了Android編程實(shí)現(xiàn)擦除Bitmap中某一塊的方法,涉及Android操作Bitmap顏色像素值調(diào)整的相關(guān)技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下2015-11-11Android Flutter實(shí)現(xiàn)GIF動(dòng)畫效果的方法詳解
如果我們想對某個(gè)組件實(shí)現(xiàn)一組動(dòng)效應(yīng)該怎么辦呢?本文將利用Android Flutter實(shí)現(xiàn)GIF動(dòng)畫效果,文中的示例代碼講解詳細(xì),需要的可以參考一下2022-06-06Android雷達(dá)掃描動(dòng)態(tài)界面制作
這篇文章主要為大家詳細(xì)介紹了Android雷達(dá)掃描動(dòng)態(tài)界面制作資料,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2016-10-10