Android點(diǎn)擊Button實(shí)現(xiàn)切換點(diǎn)擊圖片效果的示例
這是一個(gè)簡(jiǎn)單的小的DEMO , 關(guān)于點(diǎn)擊按鈕用于實(shí)現(xiàn)圖片的切換, 重要的就是里面的關(guān)于邏輯的處理, 在以后圖片輪播的技術(shù)上關(guān)于邏輯的處理和這個(gè)類(lèi)似
Android Button的點(diǎn)擊事件切換點(diǎn)擊圖片
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="184dp"
android:background="@drawable/button_selector" />
</RelativeLayout>
android:background="@drawable/button_selector"
(2)在res文件夾下創(chuàng)建drawable文件夾,創(chuàng)建一個(gè)selector文件
<?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:drawable="@drawable/q" android:state_pressed="true"></item> <item android:drawable="@drawable/w" android:state_focused="true"></item> <item android:drawable="@drawable/e"></item> </selector>

文件夾內(nèi)放三張圖片用于切換的時(shí)候改變圖片
(3)其他內(nèi)容不需要改變


文件的圖片隨著按鈕的點(diǎn)擊變化
總結(jié)
以上就是這篇文章的全部?jī)?nèi)容了,希望本文的內(nèi)容對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,謝謝大家對(duì)腳本之家的支持。如果你想了解更多相關(guān)內(nèi)容請(qǐng)查看下面相關(guān)鏈接
- Android開(kāi)發(fā)之使用ViewPager實(shí)現(xiàn)圖片左右滑動(dòng)切換效果
- Android自定義ImageView實(shí)現(xiàn)點(diǎn)擊兩張圖片切換效果
- Android編程單擊圖片實(shí)現(xiàn)切換效果的方法
- Android實(shí)現(xiàn)滑動(dòng)屏幕切換圖片
- Android中ViewPager組件的基本用法及實(shí)現(xiàn)圖片切換的示例
- Android實(shí)現(xiàn)圖片輪播切換實(shí)例代碼
- Android編程實(shí)現(xiàn)圖片背景漸變切換與圖層疊加效果
- Android 圖片切換器(dp、sp、px) 的單位轉(zhuǎn)換器
- Android控件ImageSwitcher實(shí)現(xiàn)左右圖片切換功能
- Android實(shí)現(xiàn)左右滑動(dòng)切換圖片
相關(guān)文章
Android?O對(duì)后臺(tái)Service限制詳解
這篇文章主要為大家介紹了Android?O對(duì)后臺(tái)Service限制詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2022-11-11
android listview實(shí)現(xiàn)新聞列表展示效果
這篇文章主要為大家詳細(xì)介紹了android listview實(shí)現(xiàn)新聞列表展示效果,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-03-03
Android選擇圖片或拍照?qǐng)D片上傳到服務(wù)器
這篇文章主要為大家詳細(xì)介紹了android選擇圖片或拍照?qǐng)D片上傳到服務(wù)器的方法,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-01-01
Android環(huán)形進(jìn)度條(安卓默認(rèn)形式)實(shí)例代碼
這篇文章主要介紹了Android環(huán)形進(jìn)度條(安卓默認(rèn)形式)實(shí)例代碼的相關(guān)資料,需要的朋友可以參考下2016-03-03
Android之聯(lián)系人PinnedHeaderListView使用介紹
Android聯(lián)系人中的ListView是做得比較獨(dú)特的,這幾天,我把他提取出來(lái)了,寫(xiě)成一個(gè)簡(jiǎn)單的例子,留著備用,感興趣的朋友可以參考下哈2013-06-06
Flutter開(kāi)發(fā)之Shortcuts快捷鍵組件的用法詳解
在桌面端的開(kāi)發(fā)中,鍵盤(pán)快捷鍵是非常常見(jiàn)而必要的,F(xiàn)lutter?既然可以開(kāi)發(fā)桌面端應(yīng)用,那必然要提供自定義快捷鍵,所以本文就來(lái)和大家講講Shortcuts組件的簡(jiǎn)單使用吧2023-05-05
Android大作業(yè)功能設(shè)計(jì)之自動(dòng)登錄和記住密碼
SharedPreferences是Android平臺(tái)上一個(gè)輕量級(jí)的存儲(chǔ)類(lèi),主要是保存一些常用的配置參數(shù),它是采用xml文件存放數(shù)據(jù)的,文件存放在"/data/data<package?name>/shared_prefs"目錄下,由于SharedPreferences是一個(gè)接口,而且在這個(gè)接口里沒(méi)有提供寫(xiě)入數(shù)據(jù)和讀取數(shù)據(jù)的能力2023-01-01

