Android樣式和主題之選擇器的實例講解
Android學習筆記之樣式和主題之選擇器
(1)布局文件
<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" android:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" tools:context=".MainActivity" > <Button android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:layout_alignParentLeft="true" android:layout_marginBottom="189dp" android:layout_marginLeft="55dp" android:textColor="@color/button_selector" android:text="測試顏色列表狀態(tài)" /> </RelativeLayout>
需要在按鈕里邊使用:android:textColor="@color/button_selector"
(2)需要在res目錄下創(chuàng)建一個color文件夾
button-selector文件內容如下:
<?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_pressed="true" android:color="#ffff0000"/> <item android:state_focused="true" android:color="#ff0000ff"/> <item android:color="#ff000000"/> </selector>
其他文件不做修改,默認的就可以
總結
以上就是這篇文章的全部內容了,希望本文的內容對大家的學習或者工作具有一定的參考學習價值,謝謝大家對腳本之家的支持。如果你想了解更多相關內容請查看下面相關鏈接
- Android單項綁定MVVM項目模板的方法
- Android開發(fā)實現(xiàn)的圖片瀏覽功能示例【放大圖片】
- Android開發(fā)之ListView的簡單用法及定制ListView界面操作示例
- Android實現(xiàn)自定義滑動刻度尺方法示例
- Android文字基線Baseline算法的使用講解
- Android開發(fā)實現(xiàn)ListView和adapter配合顯示圖片和文字列表功能示例
- Android使用google breakpad捕獲分析native cash
- Android應用動態(tài)修改主題的方法示例
- Android點擊Button實現(xiàn)切換點擊圖片效果的示例
- Android在ubuntu上過濾多條關鍵字日志
相關文章
Android 基礎入門教程——開發(fā)環(huán)境搭建
這篇文章主要介紹了Android 如何搭建開發(fā)環(huán)境,文中講解非常細致,幫助大家開始學習Android,想要學習Android的朋友可以了解下2020-06-06使用OkHttp包在Android中進行HTTP頭處理的教程
HTTP頭部處理是HTTP網(wǎng)絡編程中的基本操作,安卓中使用OkHttp包(github.com/square/okhttp)進行相關操作當然也是得心應手,這里我們就來看一下使用OkHttp包在Android中進行HTTP頭處理的教程2016-07-07Android有效獲取狀態(tài)欄(StatusBar)高度的方法
這篇文章主要介紹了Android有效獲取狀態(tài)欄(StatusBar)高度的方法,涉及Android針對狀態(tài)欄(StatusBar)屬性操作的相關技巧,需要的朋友可以參考下2016-08-08Android 如何實現(xiàn)exclude aar包中的某個jar包
這篇文章主要介紹了Android 如何實現(xiàn)exclude aar包中的某個jar包,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2020-03-03Android自定義ListView實現(xiàn)仿QQ可拖拽列表功能
這篇文章主要介紹了Android自定義ListView實現(xiàn)仿QQ可拖拽列表功能,非常不錯,具有參考借鑒價值,需要的朋友可以參考下2016-08-08