Android開(kāi)發(fā)返回鍵明暗點(diǎn)擊效果的實(shí)例代碼
1:在很多APP里點(diǎn)擊返回鍵,都可以看到返回鍵由亮變?yōu)榘?/p>


2:實(shí)現(xiàn)方法也是很簡(jiǎn)單的
(1)新建一個(gè)頁(yè)面
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="65dp"
android:background="#258aed"
>
//默認(rèn)的ImageView沒(méi)有可點(diǎn)擊的屬性,加入clickable添加點(diǎn)擊屬性
<ImageView
android:id="@+id/iv_back"
android:layout_width="55dp"
android:layout_height="55dp"
android:background="@drawable/iv_back_selector"
android:clickable="true"
/>
//layout_centerInParent文本居中
<TextView
android:id="@+id/tv_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="首頁(yè)"
android:layout_centerInParent="true"
android:textColor="@color/white"
android:textSize="25sp"/>
</RelativeLayout>
(2)把需要的返回箭頭圖片添加到drawable,我的這兩個(gè)圖片是阿里巴巴圖庫(kù)標(biāo)里下的

(3)在新建一個(gè)選擇器,在drawable文件里新建iv_back_selector,代碼入下,這樣就實(shí)現(xiàn)了圖片的明暗效果。
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/iv_back"
android:state_pressed="false"/>
<item android:drawable="@drawable/iv_back2"
android:state_pressed="true"/>
//選擇器,不同情況下點(diǎn)擊,選擇對(duì)應(yīng)的圖片
</selector>
到此這篇關(guān)于Android開(kāi)發(fā)返回鍵明暗點(diǎn)擊效果的文章就介紹到這了,更多相關(guān)Android返回鍵明暗點(diǎn)擊內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
- Android點(diǎn)擊事件之多點(diǎn)觸摸與手勢(shì)識(shí)別的實(shí)現(xiàn)
- Android實(shí)現(xiàn)自動(dòng)點(diǎn)擊無(wú)障礙服務(wù)功能的實(shí)例代碼
- Android自定義SeekBar實(shí)現(xiàn)滑動(dòng)驗(yàn)證且不可點(diǎn)擊
- android實(shí)現(xiàn)點(diǎn)擊按鈕控制圖片切換
- Android實(shí)現(xiàn)點(diǎn)擊某個(gè)按鈕指定位置彈出布局
- Android實(shí)現(xiàn)圖片點(diǎn)擊放大
- android實(shí)現(xiàn)點(diǎn)擊圖片全屏展示效果
- Android Button按鈕點(diǎn)擊背景和文字變化操作
- Android Studio finish()方法的使用與解決app點(diǎn)擊“返回”(直接退出)
- 關(guān)于android連續(xù)點(diǎn)擊出現(xiàn)多個(gè)Activity界面的解決方法
- Android實(shí)現(xiàn)WebView點(diǎn)擊攔截跳轉(zhuǎn)原生
- Android擴(kuò)大View點(diǎn)擊范圍的方法
相關(guān)文章
GuideView的封裝實(shí)現(xiàn)app功能引導(dǎo)頁(yè)
這篇文章主要為大家詳細(xì)介紹了GuideView的封裝實(shí)現(xiàn)app功能引導(dǎo)頁(yè),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2019-03-03
使用Android實(shí)現(xiàn)一個(gè)懸浮在軟鍵盤(pán)上的輸入欄
app開(kāi)發(fā)中經(jīng)常會(huì)遇到一些輸入框要懸浮到軟鍵盤(pán)上方的需求,下面這篇文章主要給大家介紹了關(guān)于如何使用Android實(shí)現(xiàn)一個(gè)懸浮在軟鍵盤(pán)上的輸入欄的相關(guān)資料,文中通過(guò)示例代碼介紹的非常詳細(xì),需要的朋友可以參考下2022-04-04
Android 開(kāi)發(fā)中l(wèi)ayout下的子文件夾
這篇文章主要介紹了android 開(kāi)發(fā)中l(wèi)ayout下的子文件夾,需要的朋友可以參考下2017-12-12
android利用websocket協(xié)議與服務(wù)器通信
這篇文章主要為大家詳細(xì)介紹了android利用websocket協(xié)議與服務(wù)器通信,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2018-03-03
Android頂部標(biāo)題欄的布局設(shè)計(jì)
大家好,本篇文章主要講的是Android頂部標(biāo)題欄的布局設(shè)計(jì),感興趣的同學(xué)趕快來(lái)看一看吧,對(duì)你有幫助的話記得收藏一下2022-01-01
Android內(nèi)置SQLite的使用詳細(xì)介紹
這篇文章主要介紹了Android內(nèi)置SQLite的使用詳細(xì)介紹,文章通過(guò)文章展開(kāi)詳細(xì)的內(nèi)容介紹,具有一定的參考價(jià)值,需要的小伙伴可以參考一下2022-09-09
Android App端與PHP Web端的簡(jiǎn)單數(shù)據(jù)交互實(shí)現(xiàn)示例
本篇文章主要介紹了Android App端與PHP Web端的簡(jiǎn)單數(shù)據(jù)交互實(shí)現(xiàn)示例,詳細(xì)的介紹了交互的代碼,非常具有實(shí)用價(jià)值,有興趣的可以了解一下2017-10-10
Android九宮格手勢(shì)密碼代碼設(shè)計(jì)
這篇文章主要為大家詳細(xì)介紹了Android九宮格手勢(shì)密碼的代碼設(shè)計(jì)思路,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-03-03
Android原生態(tài)實(shí)現(xiàn)分享轉(zhuǎn)發(fā)功能實(shí)例
大家好,本篇文章主要講的是Android原生態(tài)實(shí)現(xiàn)分享轉(zhuǎn)發(fā)功能實(shí)例,感興趣的同學(xué)趕快來(lái)看一看吧,對(duì)你有幫助的話記得收藏一下2021-12-12

