android開發(fā)教程之自定義控件checkbox的樣式示例
更新時間:2014年03月06日 16:12:23 作者:
這篇文章主要介紹了android自定義checkbox的樣式示例,需要的朋友可以參考下
主界面xml文件
復(fù)制代碼 代碼如下:
<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
復(fù)制代碼 代碼如下:
<?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實現(xiàn)每隔兩秒自動切換圖片功能
圖片來回自動切換,設(shè)計非常人性化,那么圖片自動切換功能基于代碼如何實現(xiàn)的呢?下面小編給大家?guī)砹薃ndroid ViewPager實現(xiàn)每隔兩秒自動切換圖片功能,感興趣的朋友一起看看吧2021-10-10使用Kotlin實現(xiàn)文字漸變TextView的代碼
這篇文章主要介紹了使用Kotlin實現(xiàn)文字漸變TextView的代碼,本文通過實例代碼給大家介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友可以參考下2020-04-04Android編程實現(xiàn)擦除Bitmap中某一塊的方法
這篇文章主要介紹了Android編程實現(xiàn)擦除Bitmap中某一塊的方法,涉及Android操作Bitmap顏色像素值調(diào)整的相關(guān)技巧,具有一定參考借鑒價值,需要的朋友可以參考下2015-11-11Android Flutter實現(xiàn)GIF動畫效果的方法詳解
如果我們想對某個組件實現(xiàn)一組動效應(yīng)該怎么辦呢?本文將利用Android Flutter實現(xiàn)GIF動畫效果,文中的示例代碼講解詳細(xì),需要的可以參考一下2022-06-06