最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Android編程之selector下設(shè)置背景屬性值的方法

 更新時(shí)間:2016年01月18日 15:46:42   作者:Leo Chin  
這篇文章主要介紹了Android編程之selector下設(shè)置背景屬性值的方法,結(jié)合實(shí)例形式分析了Android的selector背景選擇器相關(guān)使用技巧,需要的朋友可以參考下

本文實(shí)例講述了Android編程之selector下設(shè)置背景屬性值的方法。分享給大家供大家參考,具體如下:

在res/drawable文件夾新增一個(gè)文件,此文件設(shè)置了圖片的觸發(fā)狀態(tài),你可以設(shè)置 state_pressed,state_checked,state_pressed,state_selected,state_focused,state_enabled 等幾個(gè)狀態(tài):

android:state_pressed

Boolean. "true" if this item should be used when the object is pressed (such as when a button is touched/clicked); "false" if this item should be used in the default, non-pressed state.
如果是true,當(dāng)被點(diǎn)擊時(shí)顯示該圖片,如果是false沒被按下時(shí)顯示默認(rèn)。

android:state_focused

Boolean. "true" if this item should be used when the object is focused (such as when a button is highlighted using the trackball/d-pad); "false" if this item should be used in the default, non-focused state.
true,獲得焦點(diǎn)時(shí)顯示;false,沒獲得焦點(diǎn)顯示默認(rèn)。

android:state_selected

Boolean. "true" if this item should be used when the object is selected (such as when a tab is opened); "false" if this item should be used when the object is not selected.
true,當(dāng)被選擇時(shí)顯示該圖片;false,當(dāng)未被選擇時(shí)顯示該圖片。

android:state_checkable

Boolean. "true" if this item should be used when the object is checkable; "false" if this item should be used when the object is not checkable. (Only useful if the object can transition between a checkable and non-checkable widget.)
true,當(dāng)CheckBox能使用時(shí)顯示該圖片;false,當(dāng)CheckBox不能使用時(shí)顯示該圖片。

android:state_checked

Boolean. "true" if this item should be used when the object is checked; "false" if it should be used when the object is un-checked.
true,當(dāng)CheckBox選中時(shí)顯示該圖片;false,當(dāng)CheckBox為選中時(shí)顯示該圖片。

android:state_enabled

Boolean. "true" if this item should be used when the object is enabled (capable of receiving touch/click events); "false" if it should be used when the object is disabled.
true,當(dāng)該組件能使用時(shí)顯示該圖片;false,當(dāng)該組件不能使用時(shí)顯示該圖片。

android:state_window_focused

Boolean. "true" if this item should be used when the application window has focus (the application is in the foreground), "false" if this item should be used when the application window does not have focus (for example, if the notification shade is pulled down or a dialog appears).
true,當(dāng)此activity獲得焦點(diǎn)在最前面時(shí)顯示該圖片;false,當(dāng)沒在最前面時(shí)顯示該圖片。

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
  <item android:state_pressed="true"
     android:drawable="@drawable/button_pressed"/><!-- pressed -->
  <item android:state_focused="true"
     android:drawable="@drawable/button_focused"/><!-- focused -->
  <itemandroid:drawable="@drawable/button_normal"/><!-- default -->
</selector>

更多關(guān)于Android開發(fā)相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《Android開發(fā)入門與進(jìn)階教程

希望本文所述對(duì)大家Android程序設(shè)計(jì)有所幫助。

相關(guān)文章

  • Android Studio簽名打包的兩種方式(圖文教程)

    Android Studio簽名打包的兩種方式(圖文教程)

    這篇文章主要介紹了Android Studio簽名打包的兩種方式(圖文教程),文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2020-10-10
  • Android Studio安裝配置、環(huán)境搭建詳細(xì)步驟及基本使用的詳細(xì)教程

    Android Studio安裝配置、環(huán)境搭建詳細(xì)步驟及基本使用的詳細(xì)教程

    這篇文章主要介紹了Android Studio安裝配置、環(huán)境搭建詳細(xì)步驟及基本使用的詳細(xì)教程,需要的朋友可以參考下
    2020-03-03
  • Android如何在Gradle中更改APK文件名詳解

    Android如何在Gradle中更改APK文件名詳解

    這篇文章主要介紹了Android如何在Gradle中更改APK文件名的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考借鑒,下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧。
    2017-10-10
  • Android自定義加載圈的方法

    Android自定義加載圈的方法

    這篇文章主要為大家詳細(xì)介紹了Android自定義加載圈的方法,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2022-06-06
  • Android編程使用GestureDetector實(shí)現(xiàn)簡(jiǎn)單手勢(shì)監(jiān)聽與處理的方法

    Android編程使用GestureDetector實(shí)現(xiàn)簡(jiǎn)單手勢(shì)監(jiān)聽與處理的方法

    這篇文章主要介紹了Android編程使用GestureDetector實(shí)現(xiàn)簡(jiǎn)單手勢(shì)監(jiān)聽與處理的方法,簡(jiǎn)單講述了Android手勢(shì)監(jiān)聽的原理并結(jié)合實(shí)例形式分析了GestureDetector實(shí)現(xiàn)手勢(shì)監(jiān)聽與處理的相關(guān)操作技巧,需要的朋友可以參考下
    2017-09-09
  • Android自定義View繪制居中文本

    Android自定義View繪制居中文本

    這篇文章主要為大家詳細(xì)介紹了Android自定義View繪制居中文本,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2022-06-06
  • activity 獲取rootView 設(shè)置backGroundColor的方法

    activity 獲取rootView 設(shè)置backGroundColor的方法

    下面小編就為大家?guī)硪黄猘ctivity 獲取rootView 設(shè)置backGroundColor的方法。小編覺得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧
    2017-04-04
  • Android編程判斷當(dāng)前指定App是否在前臺(tái)的方法

    Android編程判斷當(dāng)前指定App是否在前臺(tái)的方法

    這篇文章主要介紹了Android編程判斷當(dāng)前指定App是否在前臺(tái)的方法,涉及Android針對(duì)進(jìn)程操作的相關(guān)技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下
    2015-11-11
  • Android實(shí)現(xiàn)固定屏幕顯示的方法

    Android實(shí)現(xiàn)固定屏幕顯示的方法

    這篇文章主要介紹了Android實(shí)現(xiàn)固定屏幕顯示的方法,實(shí)例分析了Android屏幕固定顯示所涉及的相關(guān)技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下
    2015-07-07
  • 解析android中include標(biāo)簽的使用

    解析android中include標(biāo)簽的使用

    本篇文章是對(duì)android中include標(biāo)簽的使用進(jìn)行了詳細(xì)的分析介紹,需要的朋友參考下
    2013-06-06

最新評(píng)論

灌云县| 冕宁县| 金寨县| 榆社县| 万宁市| 左权县| 清徐县| 苏尼特右旗| 安福县| 师宗县| 南投县| 榆中县| 利辛县| 涞水县| 昌黎县| 威信县| 丹寨县| 东至县| 通渭县| 宜宾县| 云和县| 化德县| 揭西县| 淮北市| 米泉市| 大悟县| 扎兰屯市| 元江| 合作市| 会昌县| 西城区| 永兴县| 鲁甸县| 辽中县| 博白县| 安泽县| 怀远县| 谢通门县| 富裕县| 自治县| 海淀区|