安德鲁斯Selector简介
xml version="1.0" encoding="utf-8"?
> <selector xmlns:android="http://schemas.android.com/apk/res/android" > <!-- 默認(rèn)情況,item必須放在最后 --> <!-- 非觸摸模式下獲得焦點(diǎn)并單擊時(shí)的背景圖片 --> <item android:state_focused="true" android:state_pressed="true" android:drawable="@drawable/ic_launcher" /> <!-- 觸摸模式下單擊時(shí)的背景圖片--> <item android:state_focused="false" android:state_pressed="true" android:drawable="@drawable/ic_launcher" /> <!--選中時(shí)的圖片背景--> <item android:state_selected="true" android:drawable="@drawable/ic_launcher" /> <!--獲得焦點(diǎn)時(shí)的圖片背景--> <item android:state_focused="true" android:drawable="@drawable/ic_launcher" /> <item android:drawable="@drawable/button_bg_default" /> </selector>
4.android:state_active="true/false" true:表示可勾選狀態(tài)時(shí)使用,false:表示不可勾選狀態(tài)下使用 5. android:state_checkable="true/false" true:表示勾選狀態(tài)下使用。false:表示非勾選狀態(tài)使用 6.android:state_checked="true/false" true:表示勾選狀態(tài)下使用。false:表示非勾選狀態(tài)使用 7. android:state_enabled="true/false" true:表示可用狀態(tài)使用(能接收觸摸/點(diǎn)擊事件)。false:表示不可用狀態(tài)使用 8. android:state_window_focused="true/false" true:表示應(yīng)用程序窗體有焦點(diǎn)時(shí)使用(應(yīng)用程序在前臺(tái)),false:表示無(wú)焦點(diǎn)時(shí)使用注意:
1、<!-- 默認(rèn)情況,item必須放在最后 -->
This item is unreachable because a previous item (item #1) is a more general match than this one ? ??
不然會(huì)出現(xiàn)就是說(shuō)第二行item之前。不能有元素出現(xiàn)。假設(shè)這樣放置,會(huì)出現(xiàn)button一直是默認(rèn)狀態(tài)。而無(wú)法獲得焦點(diǎn)的情況 ? ? ? ? ??
版權(quán)聲明:本文博客原創(chuàng)文章,博客,未經(jīng)同意,不得轉(zhuǎn)載。
轉(zhuǎn)載于:https://www.cnblogs.com/mengfanrong/p/4722355.html
創(chuàng)作挑戰(zhàn)賽新人創(chuàng)作獎(jiǎng)勵(lì)來(lái)咯,堅(jiān)持創(chuàng)作打卡瓜分現(xiàn)金大獎(jiǎng)總結(jié)
以上是生活随笔為你收集整理的安德鲁斯Selector简介的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: Git的GUI工具sourcetree的
- 下一篇: 天猫首页迷思之-jquery实现左侧广告