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文件內(nèi)容如下:
<?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>
其他文件不做修改,默認的就可以

總結(jié)
以上就是這篇文章的全部內(nèi)容了,希望本文的內(nèi)容對大家的學習或者工作具有一定的參考學習價值,謝謝大家對腳本之家的支持。如果你想了解更多相關內(nèi)容請查看下面相關鏈接
- 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檢測Activity或者Service是否運行的方法
下面小編就為大家分享一篇Android檢測Activity或者Service是否運行的方法,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2018-03-03
Android自定義View實現(xiàn)繪制水波浪溫度刻度表
這篇文章主要為大家詳細介紹了Android如何利用自定義View實現(xiàn)一個水波浪溫度刻度表,文中的示例代碼講解詳細,感興趣的小伙伴可以嘗試一下2022-11-11
Android音頻開發(fā)之SurfaceView的使用詳解
這篇文章主要為大家介紹了Android中SurfaceView的使用方法,本文通過簡要的案例,為大家進行了詳細的講解,需要的朋友可以參考一下2022-04-04
Android通過bin二進制程序調(diào)用jar原理
最近在研究monkey測試,發(fā)現(xiàn)monkey測試的代碼都是JAVA編寫的,通過編譯生成jar包,而我們在執(zhí)行測試時直接執(zhí)行/system/bin/monkey這個二進制程序的,那么它是如何能調(diào)起java程序的呢,本文小編給大家介紹了Android通過bin二進制程序調(diào)用jar原理,需要的朋友可以參考下2023-10-10

