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

Java實(shí)現(xiàn)幀動(dòng)畫的實(shí)例代碼

 更新時(shí)間:2018年05月15日 16:30:12   作者:meetings  
這篇文章主要介紹了Java實(shí)現(xiàn)幀動(dòng)畫的實(shí)例代碼,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧

本文講述了Java實(shí)現(xiàn)幀動(dòng)畫的實(shí)例代碼。分享給大家供大家參考,具體如下:

1、效果圖

2、幀動(dòng)畫的簡要代碼

private ImageView bgAnimView; 
 private AnimationDrawable mAnimationDrawable; 
//初始化 
 mAnimationDrawable = new AnimationDrawable(); 
 bgAnimView = new ImageView(mContext); 
 bgAnimView.setBackgroundDrawable(getAnimationDrawable(mAnimationDrawable)); 
 params = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); 
 params.topMargin = Util.Div(176 + 58); 
 params.gravity = Gravity.CENTER_HORIZONTAL; 
 addView(bgAnimView, params); 
private AnimationDrawable getAnimationDrawable(AnimationDrawable mAnimationDrawable) { 
 int duration = 50; 
 mAnimationDrawable.addFrame(mContext.getResources().getDrawable(R.drawable.loading1), duration); 
 mAnimationDrawable.addFrame(mContext.getResources().getDrawable(R.drawable.loading2), duration); 
 mAnimationDrawable.addFrame(mContext.getResources().getDrawable(R.drawable.loading3), duration); 
 mAnimationDrawable.setOneShot(false); 
 return mAnimationDrawable; 
 } 
 //動(dòng)畫開始 
 public void animLoadingStart() { 
 this.setVisibility(View.VISIBLE); 
 if (mAnimationDrawable != null) { 
 mAnimationDrawable.start(); 
 } 
 } 
 //動(dòng)畫結(jié)束 
 public void animLoadingEnd() { 
 if (mAnimationDrawable != null) { 
 mAnimationDrawable.stop(); 
 } 

3、擴(kuò)展:

//X軸平移 
 public void animY(int y, int nextY, int duration) { 
 LinearInterpolator ll = new LinearInterpolator(); //勻速 
 ObjectAnimator animator = ObjectAnimator.ofFloat(yourView, "translationY", 0, 300);//300若為負(fù)值,就是向上平移 
 animator.setDuration(duration); 
 animator.setInterpolator(ll); 
 animator.start(); 
 } 
//Y軸平移 
 public void animX(int x, int nextX, int duration) { 
 LinearInterpolator ll = new LinearInterpolator(); 
 ObjectAnimator animator = ObjectAnimator.ofFloat(yourView, "translationX", x, nextX); 
 animator.setDuration(duration); 
 animator.setInterpolator(ll); 
 animator.start(); 
 } 
//縱向壓縮0.5倍 
 LinearInterpolator ll = new LinearInterpolator();//勻速 
 ScaleAnimation scaleAnimation = new ScaleAnimation(1, 1, 1, 0.5f);//默認(rèn)從(0,0) 
 scaleAnimation.setDuration(500); 
 scaleAnimation.setInterpolator(ll); 
 scaleAnimation.setFillAfter(true); 
 chartView.startAnimation(scaleAnimation); 
//橫向壓縮0.5倍 
 LinearInterpolator ll = new LinearInterpolator(); 
 ScaleAnimation scaleAnimation = new ScaleAnimation(1, 0.5f, 1, 1);//默認(rèn)從(0,0) 
 scaleAnimation.setDuration(500); 
 scaleAnimation.setInterpolator(ll); 
 scaleAnimation.setFillAfter(true); 
 chartView.startAnimation(scaleAnimation); 

點(diǎn)擊打開素材下載地址

以上就是這篇文章的全部內(nèi)容了,希望本文的內(nèi)容對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,如果有疑問大家可以留言交流,謝謝大家對腳本之家的支持。

相關(guān)文章

  • JAVA實(shí)現(xiàn)KMP算法理論和示例代碼

    JAVA實(shí)現(xiàn)KMP算法理論和示例代碼

    本文從理論到代碼講解了JAVA對KMP算法的實(shí)現(xiàn),大家可以參考一下
    2013-11-11
  • Java實(shí)現(xiàn)洗牌發(fā)牌的方法

    Java實(shí)現(xiàn)洗牌發(fā)牌的方法

    這篇文章主要介紹了Java實(shí)現(xiàn)洗牌發(fā)牌的方法,涉及java針對數(shù)組的遍歷與排序操作相關(guān)技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下
    2015-07-07
  • Springboot中@Value注解的場景用法及可能遇到的問題詳解

    Springboot中@Value注解的場景用法及可能遇到的問題詳解

    這篇文章主要給大家介紹了關(guān)于Springboot中@Value注解的場景用法及可能遇到問題的相關(guān)資料, @Value通常用于注入外部化屬性,即外部配置屬性的注入,文中通過圖文介紹的非常詳細(xì),需要的朋友可以參考下
    2023-11-11
  • SpringBoot使用Log4j過程詳解

    SpringBoot使用Log4j過程詳解

    這篇文章主要介紹了SpringBoot使用Log4j過程詳解,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下
    2020-02-02
  • 淺析SpringBoot多數(shù)據(jù)源實(shí)現(xiàn)方案

    淺析SpringBoot多數(shù)據(jù)源實(shí)現(xiàn)方案

    現(xiàn)在很多項(xiàng)目的開發(fā)過程中,可能涉及到多個(gè)數(shù)據(jù)源,像讀寫分離的場景,或者因?yàn)闃I(yè)務(wù)復(fù)雜,導(dǎo)致不同的業(yè)務(wù)部署在不同的數(shù)據(jù)庫上,那么這樣的場景,我們應(yīng)該如何在代碼中簡潔方便的切換數(shù)據(jù)源呢,本文介紹SpringBoot多數(shù)據(jù)源實(shí)現(xiàn)方案,感興趣的朋友跟隨小編一起看看吧
    2024-02-02
  • Springboot+Shiro+Jwt實(shí)現(xiàn)權(quán)限控制的項(xiàng)目實(shí)踐

    Springboot+Shiro+Jwt實(shí)現(xiàn)權(quán)限控制的項(xiàng)目實(shí)踐

    如今的互聯(lián)網(wǎng)已經(jīng)成為前后端分離的時(shí)代,所以本文在使用SpringBoot整合Shiro框架的時(shí)候會(huì)聯(lián)合JWT一起搭配使用,具有一定的參考價(jià)值,感興趣的可以了解一下
    2023-09-09
  • 簡單了解Spring中常用工具類

    簡單了解Spring中常用工具類

    這篇文章主要介紹了簡單了解Spring中常用工具類,非常全面,具有一定參考價(jià)值,需要的朋友可以了解下。
    2017-10-10
  • Java實(shí)現(xiàn)學(xué)生管理系統(tǒng)(IO版)

    Java實(shí)現(xiàn)學(xué)生管理系統(tǒng)(IO版)

    這篇文章主要為大家詳細(xì)介紹了Java實(shí)現(xiàn)學(xué)生管理系統(tǒng),文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2022-02-02
  • 解決微服務(wù)feign調(diào)用添加token的問題

    解決微服務(wù)feign調(diào)用添加token的問題

    這篇文章主要介紹了解決微服務(wù)feign調(diào)用添加token的問題,具有很好的參考價(jià)值,希望對大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2021-06-06
  • Java線程中的線程本地變量ThreadLocal詳解

    Java線程中的線程本地變量ThreadLocal詳解

    這篇文章主要介紹了Java線程中的線程本地變量ThreadLocal詳解,ThreadLocal存放的值是線程內(nèi)共享的,線程間互斥的,主要用于線程內(nèi)共享一些數(shù)據(jù),避免通過參數(shù)來傳遞,這樣處理后,能夠優(yōu)雅的解決一些實(shí)際問題,需要的朋友可以參考下
    2023-11-11

最新評論