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è)類似

創(chuàng)新互聯(lián)專業(yè)為企業(yè)提供紅古網(wǎng)站建設(shè)、紅古做網(wǎng)站、紅古網(wǎng)站設(shè)計(jì)、紅古網(wǎng)站制作等企業(yè)網(wǎng)站建設(shè)、網(wǎng)頁(yè)設(shè)計(jì)與制作、紅古企業(yè)網(wǎng)站模板建站服務(wù),10多年紅古做網(wǎng)站經(jīng)驗(yàn),不只是建網(wǎng)站,更提供有價(jià)值的思路和整體網(wǎng)絡(luò)服務(wù)。

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>

Android點(diǎn)擊Button實(shí)現(xiàn)切換點(diǎn)擊圖片效果的示例

文件夾內(nèi)放三張圖片用于切換的時(shí)候改變圖片

(3)其他內(nèi)容不需要改變

Android點(diǎn)擊Button實(shí)現(xiàn)切換點(diǎn)擊圖片效果的示例

Android點(diǎn)擊Button實(shí)現(xiàn)切換點(diǎn)擊圖片效果的示例

文件的圖片隨著按鈕的點(diǎn)擊變化

總結(jié)

以上就是這篇文章的全部?jī)?nèi)容了,希望本文的內(nèi)容對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,謝謝大家對(duì)創(chuàng)新互聯(lián)的支持。如果你想了解更多相關(guān)內(nèi)容請(qǐng)查看下面相關(guān)鏈接

網(wǎng)站標(biāo)題:Android點(diǎn)擊Button實(shí)現(xiàn)切換點(diǎn)擊圖片效果的示例
新聞來源:http://muchs.cn/article2/ipgoic.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供標(biāo)簽優(yōu)化、企業(yè)建站、外貿(mào)網(wǎng)站建設(shè)網(wǎng)站內(nèi)鏈、網(wǎng)站建設(shè)外貿(mào)建站

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)

綿陽服務(wù)器托管