欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Android 使用selector改變按鈕狀態(tài)實(shí)例詳解

 更新時(shí)間:2017年01月28日 10:12:08   投稿:lqh  
這篇文章主要介紹了Android 使用selector改變按鈕狀態(tài)實(shí)例詳解的相關(guān)資料,需要的朋友可以參考下

Android 使用selector改變按鈕狀態(tài)實(shí)例詳解

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

state_pressed,state_checked,state_pressed,state_selected,state_focused,state_enabled 等幾個(gè)狀態(tài):

< selector xmlns:android="http://schemas.android.com/apk/res/android">

< item android:state_pressed="true" android:drawable="@drawable/arrow_pressed" />

< item android:drawable="@drawable/arrow_normal" />

< item android:state_checked="true" android:drawable="@drawable/arrow_pressed" />

< /selector>

 其中的android:src="@drawable/imageselector"

< ImageView 
android:layout_width="wrap_content"
android:layout_height="@android:dimen/app_icon_size"
android:layout_alignParentRight="true" 
android:scaleType="fitCenter"
android:layout_gravity="center" 
android:src="@drawable/imageselector"
android:clickable="true" 
android:focusable="true" 
android:id="@+id/blacklistImageView"
android:layout_marginRight="10dip" />

 如果當(dāng)觸發(fā)的控件不是ImageView,而是別的控件,可在代碼中用

blacklistImageView.setPressed(true);
 
blacklistImageView.setChecked(true);

感謝閱讀,希望能幫助到大家,謝謝大家對(duì)本站的支持!

相關(guān)文章

  • Android中TelephonyManager類(lèi)的用法案例詳解

    Android中TelephonyManager類(lèi)的用法案例詳解

    這篇文章主要介紹了Android中TelephonyManager類(lèi)的用法,以獲取Android手機(jī)硬件信息為例詳細(xì)分析了TelephonyManager類(lèi)的使用技巧,需要的朋友可以參考下
    2015-09-09
  • Android XML數(shù)據(jù)解析簡(jiǎn)單示例

    Android XML數(shù)據(jù)解析簡(jiǎn)單示例

    這篇文章主要介紹了Android XML數(shù)據(jù)解析簡(jiǎn)單示例,本文直接給出了實(shí)現(xiàn)代碼,需要的朋友可以參考下
    2014-10-10
  • Kotlin自定義菜單控件

    Kotlin自定義菜單控件

    這篇文章主要為大家詳細(xì)介紹了Kotlin自定義菜單控件,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2018-07-07
  • Android中監(jiān)聽(tīng)系統(tǒng)網(wǎng)絡(luò)連接打開(kāi)或者關(guān)閉的實(shí)現(xiàn)代碼

    Android中監(jiān)聽(tīng)系統(tǒng)網(wǎng)絡(luò)連接打開(kāi)或者關(guān)閉的實(shí)現(xiàn)代碼

    本篇文章對(duì)Android中監(jiān)聽(tīng)系統(tǒng)網(wǎng)絡(luò)連接打開(kāi)或者關(guān)閉的實(shí)現(xiàn)用實(shí)例進(jìn)行了介紹。需要的朋友參考下
    2013-05-05
  • Android中的Bitmap緩存池使用詳解

    Android中的Bitmap緩存池使用詳解

    這篇文章主要介紹了Android中的Bitmap緩存池使用詳解,本文主要目的是講解如何使用緩存來(lái)提高UI的載入輸入和滑動(dòng)的流暢性,需要的朋友可以參考下
    2015-01-01
  • Android設(shè)計(jì)模式之單例模式實(shí)例

    Android設(shè)計(jì)模式之單例模式實(shí)例

    這篇文章主要介紹了Android設(shè)計(jì)模式之單例模式實(shí)例,單例模式是運(yùn)用最廣泛的設(shè)計(jì)模式之一,在應(yīng)用這個(gè)模式時(shí),單例模式的類(lèi)必須保證只有一個(gè)實(shí)例存在
    2023-04-04
  • Android自定義view之太極圖的實(shí)現(xiàn)教程

    Android自定義view之太極圖的實(shí)現(xiàn)教程

    這篇文章主要給大家介紹了關(guān)于Android自定義view之太極圖的相關(guān)資料,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧
    2021-01-01
  • Android沉浸式狀態(tài)欄實(shí)現(xiàn)示例

    Android沉浸式狀態(tài)欄實(shí)現(xiàn)示例

    本篇文章主要介紹了Android沉浸式狀態(tài)欄實(shí)現(xiàn)示例,小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧
    2017-02-02
  • Android實(shí)現(xiàn)的簡(jiǎn)單藍(lán)牙程序示例

    Android實(shí)現(xiàn)的簡(jiǎn)單藍(lán)牙程序示例

    這篇文章主要介紹了Android實(shí)現(xiàn)的簡(jiǎn)單藍(lán)牙程序,結(jié)合實(shí)例形式分析了Android藍(lán)牙程序的原理與客戶端、服務(wù)器端具體實(shí)現(xiàn)步驟,需要的朋友可以參考下
    2016-10-10
  • Android實(shí)現(xiàn)類(lèi)似微信的文本輸入框 效果

    Android實(shí)現(xiàn)類(lèi)似微信的文本輸入框 效果

    本文給大家介紹一下微信的文本輸入框是如何實(shí)現(xiàn)的,其實(shí)那只是個(gè)普通的文本框設(shè)了一個(gè)特殊的背景而已。具體微信怎么實(shí)現(xiàn)的,大家可以反編譯下,這里介紹下如何實(shí)現(xiàn)這個(gè)背景
    2017-05-05

最新評(píng)論