Android點(diǎn)擊Button實(shí)現(xiàn)切換點(diǎn)擊圖片效果的示例
這是一個(gè)簡單的小的DEMO , 關(guān)于點(diǎn)擊按鈕用于實(shí)現(xiàn)圖片的切換, 重要的就是里面的關(guān)于邏輯的處理, 在以后圖片輪播的技術(shù)上關(guān)于邏輯的處理和這個(gè)類似
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é)
以上就是這篇文章的全部內(nèi)容了,希望本文的內(nèi)容對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,謝謝大家對(duì)腳本之家的支持。如果你想了解更多相關(guān)內(nèi)容請(qǐng)查看下面相關(guān)鏈接
- Android開發(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 控制wifi 相關(guān)操作實(shí)例
本篇文章主要介紹了Android 控制wifi 的開發(fā)實(shí)例,并附有實(shí)例源碼等相關(guān)資料,需要的朋友可以參考下2016-07-07淺談Android性能優(yōu)化之內(nèi)存優(yōu)化
Android的內(nèi)存優(yōu)化是性能優(yōu)化中很重要的一部分,本文將詳細(xì)介紹Android性能優(yōu)化之內(nèi)存優(yōu)化。2021-06-06揭秘在ListView等AdapterView上動(dòng)態(tài)添加刪除項(xiàng)的陷阱
今天遇到這么個(gè)需求,需要在運(yùn)行時(shí)動(dòng)態(tài)添加ListView的item,看起來很簡單,實(shí)際操作過程中卻遇到了麻煩,下面揭秘在ListView等AdapterView上動(dòng)態(tài)添加刪除項(xiàng)的陷阱2016-04-04使用DrawerLayout完成滑動(dòng)菜單的示例代碼
這篇文章主要介紹了使用DrawerLayout完成滑動(dòng)菜單的示例代碼,代碼簡單易懂,非常不錯(cuò),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2020-08-08Android實(shí)現(xiàn)購物車添加物品的動(dòng)畫效果
本文主要介紹了Android實(shí)現(xiàn)購物車添加物品動(dòng)畫效果的示例代碼。具有很好的參考價(jià)值,下面跟著小編一起來看下吧2017-03-03完美解決Android三星手機(jī)從圖庫選擇照片旋轉(zhuǎn)問題
這篇文章主要幫助大家完美解決了Android三星手機(jī)從圖庫選擇照片旋轉(zhuǎn)問題,很實(shí)用的解決小案例,感興趣的小伙伴們可以參考一下2016-04-04Android編程實(shí)現(xiàn)動(dòng)畫自動(dòng)播放功能
這篇文章主要介紹了Android編程實(shí)現(xiàn)動(dòng)畫自動(dòng)播放功能,結(jié)合實(shí)例形式分析了Android動(dòng)畫自動(dòng)播放功能的實(shí)現(xiàn)方法與相關(guān)注意事項(xiàng),需要的朋友可以參考下2017-07-07Android模塊化中數(shù)據(jù)傳遞/路由跳轉(zhuǎn)實(shí)現(xiàn)示例
這篇文章主要介紹了Android模塊化中數(shù)據(jù)傳遞/路由跳轉(zhuǎn)實(shí)現(xiàn)示例,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2018-07-07Kotlin整合Vertx開發(fā)Web應(yīng)用
這篇文章主要介紹了Kotlin整合Vertx開發(fā)Web應(yīng)用,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2019-02-02