使用定義在xml下的動畫

一、Drawable Animation

<animation-list>爲根元素,以<item>表示要輪換顯示的圖片,duration屬性表示各項顯示的時間。
XML文件要放在/res/drawable/目錄下
anim = (AnimationDrawable) imageView.getBackground();   

anim.stop();   anim.start();


二、Tweene

 res文件夾下建立anim文件夾
ser-<set>
alpha-<alpha>
scale-<scale>
....
Animation animation = AnimationUtils.loadAnimation(context, R.anim.xx);


三、屬性動畫

在XML聲明中所使用的對應的XML標籤:
ValueAnimator- <animator>
ObjectAnimator- <objectAnimator>
AnimatorSet- <set>
ObjectAnimator scaleAnimator = (ObjectAnimator) AnimatorInflater.loadAnimator(this, R.animator.scale_object_animator);  scaleAnimator.setTarget(imageview_scale);//設置動畫作用的目標對象


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章