日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

三个小李子讲述安卓动画用法

發布時間:2023/12/20 编程问答 40 豆豆
生活随笔 收集整理的這篇文章主要介紹了 三个小李子讲述安卓动画用法 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

這里通過三個小李子來講述一下,Android中通過xml獲取三種動畫的方法。

屬性動畫:從api 11引入

<!--animator/alpha_animator.xml--> <objectAnimator xmlns:android="http://schemas.android.com/apk/res/android"android:duration="5000"android:propertyName="alpha"android:valueFrom="0.0f"android:valueTo="1.0f"></objectAnimator> ImageView imageView = new ImageView(this);setContentView(imageView);imageView.setImageResource(R.drawable.icon_0);ObjectAnimator objectAnimator = (ObjectAnimator) AnimatorInflater.loadAnimator(this, R.animator.alpha_animator);objectAnimator.setTarget(imageView);objectAnimator.start();

視圖動畫:常用alpha/scale/translate/rotate

<!--anim/test.xml--> <set xmlns:android="http://schemas.android.com/apk/res/android"android:interpolator="@android:anim/accelerate_interpolator"><rotate android:duration="1000"android:fromDegrees="0"android:pivotX="50%"android:pivotY="50%"android:startOffset="500"android:toDegrees="360" /><alpha android:duration="500"android:fromAlpha="1.0"android:startOffset="500"android:toAlpha="0.0"></alpha><scale android:duration="500"android:fromXScale="1.0"android:fromYScale="1.0"android:pivotX="50%"android:pivotY="50%"android:startOffset="500"android:toXScale="0"android:toYScale="0"></scale> </set> ImageView imageView = new ImageView(this);setContentView(imageView);imageView.setImageResource(R.drawable.icon_0);Animation animation = AnimationUtils.loadAnimation(this, R.anim.test);imageView.setAnimation(animation);animation.start();

幀動畫:幾張圖片的有規律出現

<?xml version="1.0" encoding="utf-8"?> <!--drawable/test.xml--> <animation-list xmlns:android="http://schemas.android.com/apk/res/android"><item android:drawable="@drawable/icon_0"android:duration="500"></item><item android:drawable="@drawable/icon_bg_release_topic_a"android:duration="500"></item><item android:drawable="@drawable/icon_1"android:duration="1000"></item></animation-list> ImageView imageView = new ImageView(this);setContentView(imageView);imageView.setBackgroundResource(R.drawable.test);AnimationDrawable animationDrawable = (AnimationDrawable) imageView.getBackground();animationDrawable.start();

總結

以上是生活随笔為你收集整理的三个小李子讲述安卓动画用法的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。