国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發(fā) > Java > 正文

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

2024-07-14 08:40:50
字體:
供稿:網(wǎng)友

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

1、效果圖

java,幀動(dòng)畫,代碼,java幀動(dòng)畫代碼

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à)值,如果有疑問大家可以留言交流,謝謝大家對VeVb武林網(wǎng)的支持。


注:相關(guān)教程知識閱讀請移步到JAVA教程頻道。
發(fā)表評論 共有條評論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 烟台市| 神木县| 越西县| 治多县| 陇川县| 宾川县| 南靖县| 丹巴县| 务川| 和田县| 塘沽区| 慈溪市| 张家川| 余庆县| 灌南县| 盐池县| 称多县| 邳州市| 洪洞县| 麟游县| 沁阳市| 高要市| 英德市| 永清县| 简阳市| 武功县| 纳雍县| 莆田市| 成安县| 河西区| 乐业县| 平原县| 克拉玛依市| 大关县| 增城市| 赞皇县| 龙井市| 天门市| 沐川县| 长白| 闽侯县|