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

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

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

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

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

再drawable目錄下新建animation1文件和animation2文件  一個是按順序顯示動畫,一個是倒序顯示動畫,

順序顯示動畫文件:animation1.xml

<?xml version="1.0" encoding="utf-8"?> 
<!--  
  根標(biāo)簽為animation-list,其中oneshot代表著是否只展示一遍,設(shè)置為false會不停的循環(huán)播放動畫 
  根標(biāo)簽下,通過item標(biāo)簽對動畫中的每一個圖片進(jìn)行聲明 
  android:duration 表示展示所用的該圖片的時(shí)間長度 
 --> 
<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> 

倒序顯示動畫文件:animation2.xml

<?xml version="1.0" encoding="utf-8"?> 
<!--  
  根標(biāo)簽為animation-list,其中oneshot代表著是否只展示一遍,設(shè)置為false會不停的循環(huán)播放動畫 
  根標(biāo)簽下,通過item標(biāo)簽對動畫中的每一個圖片進(jìn)行聲明 
  android:duration 表示展示所用的該圖片的時(shí)間長度 
 --> 
<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(); 
      }       
    });     
  } 
} 

以上就是本文的全部內(nèi)容,希望對大家的學(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)常會遇到需要動態(tài)隱藏或顯示組件的需求,Flutter 提供了多種方式來實(shí)現(xiàn)這一功能,每種方式都有其獨(dú)特的適用場景,本文將深入探討這些方法的原理、用法以及優(yōu)缺點(diǎn),幫助您選擇最適合的方案,需要的朋友可以參考下
    2024-10-10
  • Android 實(shí)現(xiàn)微信長按菜單 -FloatMenu

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

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

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

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

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

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

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

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

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

    這篇文章主要介紹了Android?實(shí)現(xiàn)卡片堆疊錢包管理動畫效果,實(shí)現(xiàn)思路是在動畫回調(diào)中requestLayout?實(shí)現(xiàn)動畫效果,用Bounds?對象記錄每一個CardView?對象的初始位置,當(dāng)前位置,運(yùn)動目標(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)鍵詞批量搜索示例,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2017-02-02
  • 淺談Android串口通訊SerialPort原理

    淺談Android串口通訊SerialPort原理

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

最新評論

汉源县| 新乡市| 兰坪| 广东省| 崇文区| 绩溪县| 沾化县| 孟村| 新泰市| 金昌市| 秀山| 平和县| 阿城市| 湖口县| 望城县| 东山县| 阜新市| 孟连| 桑日县| 交口县| 沁水县| 玉门市| 沙雅县| 墨玉县| 福安市| 中宁县| 鲁山县| 黄大仙区| 安溪县| 鄯善县| 长沙市| 永济市| 南雄市| 肃南| 郑州市| 阿勒泰市| 会同县| 临夏县| 正蓝旗| 菏泽市| 蓝田县|