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

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

 更新時(shí)間:2019年03月30日 09:34:44   作者:徐劉根  
今天小編就為大家分享一篇關(guān)于Android點(diǎn)擊Button實(shí)現(xiàn)切換點(diǎn)擊圖片效果的示例,小編覺得內(nèi)容挺不錯(cuò)的,現(xiàn)在分享給大家,具有很好的參考價(jià)值,需要的朋友一起跟隨小編來看看吧

這是一個(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)鏈接

相關(guān)文章

最新評(píng)論