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

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

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

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

在res/drawable文件夾新增一個文件,此文件設置了圖片的觸發(fā)狀態(tài),你可以設置 state_pressed,state_checked,state_pressed,state_selected,state_focused,state_enabled 等幾個狀態(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,當被點擊時顯示該圖片,如果是false沒被按下時顯示默認。

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,獲得焦點時顯示;false,沒獲得焦點顯示默認。

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,當被選擇時顯示該圖片;false,當未被選擇時顯示該圖片。

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,當CheckBox能使用時顯示該圖片;false,當CheckBox不能使用時顯示該圖片。

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,當CheckBox選中時顯示該圖片;false,當CheckBox為選中時顯示該圖片。

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,當該組件能使用時顯示該圖片;false,當該組件不能使用時顯示該圖片。

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,當此activity獲得焦點在最前面時顯示該圖片;false,當沒在最前面時顯示該圖片。

<?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>

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

希望本文所述對大家Android程序設計有所幫助。

相關文章

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

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

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

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

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

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

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

    Android自定義加載圈的方法

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

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

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

    Android自定義View繪制居中文本

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

    activity 獲取rootView 設置backGroundColor的方法

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

    Android編程判斷當前指定App是否在前臺的方法

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

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

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

    解析android中include標簽的使用

    本篇文章是對android中include標簽的使用進行了詳細的分析介紹,需要的朋友參考下
    2013-06-06

最新評論

乌拉特后旗| 沂水县| 五华县| 上犹县| 岫岩| 廊坊市| 阿拉善盟| 武义县| 崇义县| 河间市| 澄城县| 新化县| 友谊县| 前郭尔| 东平县| 静乐县| 台中县| 永平县| 泗水县| 兴海县| 淮阳县| 阿坝| 思茅市| 怀集县| 镇沅| 荣昌县| 奉贤区| 册亨县| 连山| 宝应县| 商河县| 镇安县| 泉州市| 西乌珠穆沁旗| 砀山县| 望谟县| 宁南县| 新乐市| 青冈县| 遂平县| 宾阳县|