最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Android利用animation-list實(shí)現(xiàn)幀動(dòng)畫

 更新時(shí)間:2017年12月25日 10:41:29   作者:Angel_jn  
這篇文章主要為大家詳細(xì)介紹了Android利用animation-list實(shí)現(xiàn)幀動(dòng)畫,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

本文實(shí)例為大家分享了利用animation-list實(shí)現(xiàn)幀動(dòng)畫的具體代碼,供大家參考,具體內(nèi)容如下

將要順序播放的圖片放在資源目錄下

再drawable目錄下新建animation1文件和animation2文件  一個(gè)是按順序顯示動(dòng)畫,一個(gè)是倒序顯示動(dòng)畫,

順序顯示動(dòng)畫文件:animation1.xml

<?xml version="1.0" encoding="utf-8"?> 
<!--  
  根標(biāo)簽為animation-list,其中oneshot代表著是否只展示一遍,設(shè)置為false會(huì)不停的循環(huán)播放動(dòng)畫 
  根標(biāo)簽下,通過item標(biāo)簽對(duì)動(dòng)畫中的每一個(gè)圖片進(jìn)行聲明 
  android:duration 表示展示所用的該圖片的時(shí)間長(zhǎng)度 
 --> 
<animation-list 
 xmlns:android="http://schemas.android.com/apk/res/android" 
 android:oneshot="true" 
 > 
  <item android:drawable="@drawable/icon1" android:duration="150"></item> 
  <item android:drawable="@drawable/icon2" android:duration="150"></item> 
  <item android:drawable="@drawable/icon3" android:duration="150"></item> 
  <item android:drawable="@drawable/icon4" android:duration="150"></item> 
  <item android:drawable="@drawable/icon5" android:duration="150"></item> 
  <item android:drawable="@drawable/icon6" android:duration="150"></item> 
</animation-list> 

倒序顯示動(dòng)畫文件:animation2.xml

<?xml version="1.0" encoding="utf-8"?> 
<!--  
  根標(biāo)簽為animation-list,其中oneshot代表著是否只展示一遍,設(shè)置為false會(huì)不停的循環(huán)播放動(dòng)畫 
  根標(biāo)簽下,通過item標(biāo)簽對(duì)動(dòng)畫中的每一個(gè)圖片進(jìn)行聲明 
  android:duration 表示展示所用的該圖片的時(shí)間長(zhǎng)度 
 --> 
<animation-list 
 xmlns:android="http://schemas.android.com/apk/res/android" 
 android:oneshot="true" 
 > 
  <item android:drawable="@drawable/icon6" android:duration="150"></item> 
  <item android:drawable="@drawable/icon5" android:duration="150"></item> 
  <item android:drawable="@drawable/icon4" android:duration="150"></item> 
  <item android:drawable="@drawable/icon3" android:duration="150"></item> 
  <item android:drawable="@drawable/icon2" android:duration="150"></item> 
  <item android:drawable="@drawable/icon1" android:duration="150"></item> 
</animation-list> 

布局文件

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
  android:layout_width="fill_parent" 
  android:layout_height="fill_parent" 
  android:orientation="vertical"> 
   
  <ImageView android:id="@+id/animationIV" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:padding="5px" 
      android:src="@drawable/animation1"/>  
       
  <Button android:id="@+id/buttonA" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:padding="5px" 
    android:text="順序顯示" /> 
   
  <Button android:id="@+id/buttonB" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:padding="5px" 
    android:text="停止" /> 
   
  <Button android:id="@+id/buttonC" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:padding="5px" 
    android:text="倒序顯示" /> 
 
</LinearLayout> 

Activity文件

package org.shuxiang.test; 
 
import android.app.Activity; 
import android.graphics.drawable.AnimationDrawable; 
 
import android.os.Bundle; 
import android.view.View; 
import android.view.View.OnClickListener; 
import android.view.Window; 
import android.widget.Button; 
import android.widget.ImageView; 
 
public class Activity10 extends Activity 
{ 
  private ImageView animationIV; 
  private Button buttonA, buttonB, buttonC; 
  private AnimationDrawable animationDrawable; 
  @Override 
  public void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    requestWindowFeature(Window.FEATURE_NO_TITLE); 
    setContentView(R.layout.test10); 
     
     
    animationIV = (ImageView) findViewById(R.id.animationIV); 
    buttonA = (Button) findViewById(R.id.buttonA); 
    buttonB = (Button) findViewById(R.id.buttonB); 
    buttonC = (Button) findViewById(R.id.buttonC); 
     
    buttonA.setOnClickListener(new OnClickListener() 
    { 
      @Override 
      public void onClick(View v) { 
        // TODO Auto-generated method stub 
        animationIV.setImageResource(R.drawable.animation1); 
        animationDrawable = (AnimationDrawable) animationIV.getDrawable(); 
        animationDrawable.start(); 
      } 
       
    });  
     
    buttonB.setOnClickListener(new OnClickListener() 
    { 
      @Override 
      public void onClick(View v) { 
        // TODO Auto-generated method stub 
        animationDrawable = (AnimationDrawable) animationIV.getDrawable(); 
        animationDrawable.stop(); 
      } 
       
    }); 
     
    buttonC.setOnClickListener(new OnClickListener() 
    { 
      @Override 
      public void onClick(View v) { 
        // TODO Auto-generated method stub 
        animationIV.setImageResource(R.drawable.animation2); 
        animationDrawable = (AnimationDrawable) animationIV.getDrawable(); 
        animationDrawable.start(); 
      }       
    });     
  } 
} 

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • android實(shí)現(xiàn)多點(diǎn)觸摸應(yīng)用

    android實(shí)現(xiàn)多點(diǎn)觸摸應(yīng)用

    這篇文章主要為大家詳細(xì)介紹了android實(shí)現(xiàn)多點(diǎn)觸摸應(yīng)用,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2022-05-05
  • Android  Surfaceview的繪制與應(yīng)用

    Android Surfaceview的繪制與應(yīng)用

    這篇文章主要介紹了Android Surfaceview的繪制與應(yīng)用的相關(guān)資料,需要的朋友可以參考下
    2017-07-07
  • Flutter組件隱藏的多種方式總結(jié)

    Flutter組件隱藏的多種方式總結(jié)

    在 Flutter 開發(fā)中,我們經(jīng)常會(huì)遇到需要?jiǎng)討B(tài)隱藏或顯示組件的需求,Flutter 提供了多種方式來實(shí)現(xiàn)這一功能,每種方式都有其獨(dú)特的適用場(chǎng)景,本文將深入探討這些方法的原理、用法以及優(yōu)缺點(diǎn),幫助您選擇最適合的方案,需要的朋友可以參考下
    2024-10-10
  • Android 實(shí)現(xiàn)微信長(zhǎng)按菜單 -FloatMenu

    Android 實(shí)現(xiàn)微信長(zhǎng)按菜單 -FloatMenu

    在日常開發(fā)中,長(zhǎng)按某個(gè)view出現(xiàn)個(gè)菜單是很常見的需求,下面小編給大家?guī)砹薃ndroid 實(shí)現(xiàn)微信長(zhǎng)按菜單 -FloatMenu的實(shí)現(xiàn)思路及具體實(shí)現(xiàn)代碼,感興趣的朋友跟隨腳本之家小編一起看看吧
    2018-07-07
  • 詳解如何實(shí)現(xiàn)一個(gè)Kotlin函數(shù)類型

    詳解如何實(shí)現(xiàn)一個(gè)Kotlin函數(shù)類型

    這篇文章主要為大家詳細(xì)介紹了如何實(shí)現(xiàn)一個(gè)Kotlin函數(shù)類型,文中的實(shí)現(xiàn)方法講解詳細(xì),具有一定的借鑒價(jià)值,需要的小伙伴可以跟隨小編一起學(xué)習(xí)一下
    2022-10-10
  • Android應(yīng)用隱私合規(guī)檢測(cè)實(shí)現(xiàn)方案詳解

    Android應(yīng)用隱私合規(guī)檢測(cè)實(shí)現(xiàn)方案詳解

    這篇文章主要介紹了Android應(yīng)用隱私合規(guī)檢測(cè)實(shí)現(xiàn)方案,我們需要做的就是提前檢測(cè)好自己的應(yīng)用是否存在隱私合規(guī)問題,及時(shí)整改過來,下面提供Xposed Hook思路去檢測(cè)隱私合規(guī)問題,建議有Xposed基礎(chǔ)的童鞋閱讀,需要的朋友可以參考下
    2022-07-07
  • Android二級(jí)緩存加載圖片實(shí)現(xiàn)照片墻功能

    Android二級(jí)緩存加載圖片實(shí)現(xiàn)照片墻功能

    這篇文章主要為大家詳細(xì)介紹了Android二級(jí)緩存加載圖片實(shí)現(xiàn)照片墻功能,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2017-07-07
  • Android?實(shí)現(xiàn)卡片堆疊錢包管理動(dòng)畫效果

    Android?實(shí)現(xiàn)卡片堆疊錢包管理動(dòng)畫效果

    這篇文章主要介紹了Android?實(shí)現(xiàn)卡片堆疊錢包管理動(dòng)畫效果,實(shí)現(xiàn)思路是在動(dòng)畫回調(diào)中requestLayout?實(shí)現(xiàn)動(dòng)畫效果,用Bounds?對(duì)象記錄每一個(gè)CardView?對(duì)象的初始位置,當(dāng)前位置,運(yùn)動(dòng)目標(biāo)位置,需要的朋友可以參考下
    2022-07-07
  • Android EditText實(shí)現(xiàn)關(guān)鍵詞批量搜索示例

    Android EditText實(shí)現(xiàn)關(guān)鍵詞批量搜索示例

    本篇文章主要介紹了Android EditText實(shí)現(xiàn)關(guān)鍵詞批量搜索示例,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧
    2017-02-02
  • 淺談Android串口通訊SerialPort原理

    淺談Android串口通訊SerialPort原理

    這篇文章主要介紹了淺談Android串口通訊SerialPort原理,文章圍繞主題展開詳細(xì)的內(nèi)容介紹,具有一定的參考價(jià)值,需要的小伙伴可以參考一下
    2022-09-09

最新評(píng)論

交城县| 明溪县| 临清市| 莎车县| 南宁市| 普宁市| 平阳县| 定日县| 襄垣县| 苍溪县| 孙吴县| 鸡泽县| 达日县| 连南| 盐津县| 广东省| 新建县| 武定县| 南华县| 横峰县| 延津县| 龙泉市| 革吉县| 鸡泽县| 纳雍县| 定远县| 会理县| 横峰县| 西和县| 息烽县| 南开区| 龙游县| 凤翔县| 临沭县| 长垣县| 奉化市| 大化| 彭水| 军事| 潞城市| 永顺县|