android中的animation
『壹』 Android 中的動畫有哪幾類,它們的特點和區別是什麼
Android包含三種動畫:
ViewAnimation、 Drawable Animation、Property Animation。
ViewAnimation(Tween Animation補間動畫):
動畫的對象除了傳統的View對象,還可以是Object對象,動畫之後,Object對象的屬性值被實實在在的改變了。Property animation能夠通過改變View對象的實際屬性來實現View動畫。任何時候View屬性的改變,View能自動調用invalidate()來刷新。
『貳』 Android 中 Animation 怎麼停止
最近遇到一個需求,通過在GridView上改變焦點,並且GridView上每個item有一個隱藏的層,獲取焦點之後,通過AlphaAnimation顯示出來。
發現當ration大於500時,快速移動焦點,每個item都會播放一次動畫。
需求是焦點移動到別的item,當前item的動畫停止。
通過測試發現,調用Animation中的cancel()方法不能實現這樣的效果。
我使用了以下方法,均未成功:
1.調用Animation的cancel()方法;
2.將播放動畫的view invisible。
3.將正在播放的動畫置null。
在國外的一個論壇中,找到了結果。
調用view中的clearAnimation()方法,即可消除view上正在運行的動畫效果。
『叄』 android之animator 和animation 的區別
一、 前言
Animator框架是Android 4.0中新添加的一個動畫框架,和之前的Animation框架相比,Animator可以進行更多和更精細化的動畫控制,而且比之前更簡單和更高效。在4.0源碼中隨處都可以看到Animator的使用。
二、 Animation和Animator比較
如下圖,是Animation和Animator兩個類繼承圖的對比。
C:Object C:Object
C:Animation C:Animator
C:AlphaAnimation C:AnimatorSet
C:AnimationSet C:ValueAnimator
C:DummyAnimation C:ObjectAnimator
C:Rotate3dAnimation C:TimeAnbimator
C:RotateAniamtion
C:ScaleAnimation
C:TranslateAnimation
Animation框架定義了透明度,旋轉,縮放和位移幾種常見的動畫,而且控制的是一個整個View動畫,實現原理是每次繪制視圖時View所在的ViewGroup中的drawChild函數獲取該View的Animation的Transformation值,然後調用canvas.concat(transformToApply.getMatrix()),通過矩陣運算完成動畫幀,如果動畫沒有完成,繼續調用invalidate()函數,啟動下次繪制來驅動動畫,動畫過程中的幀之間間隙時間是繪制函數所消耗的時間,可能會導致動畫消耗比較多的CPU資源。
在Animator框架中使用最多的是AnimatorSet和ObjectAnimator配合,使用ObjectAnimator進行更精細化控制,只控制一個對象的一個屬性值,多個ObjectAnimator組合到AnimatorSet形成一個動畫。而且ObjectAnimator能夠自動驅動,可以調用setFrameDelay(longframeDelay)設置動畫幀之間的間隙時間,調整幀率,減少動畫過程中頻繁繪制界面,而在不影響動畫效果的前提下減少CPU資源消耗。
三、 關鍵介面介紹
1. ObjectAnimator介紹
Animator框架封裝得比較完美,對外提供的介面非常簡單,創建一個ObjectAnimator只需通過如下圖所示的靜態工廠類直接返回一個ObjectAnimator對象。傳的參數包括一個對象和對象的屬性名字,但這個屬性必須有get和set函數,內部會通過java反射機制來調用set函數修改對象屬性值。還包括屬性的初始值,最終值,還可以調用setInterpolator設置曲線函數。
2. AnimatorSet介紹
AnimatorSet主要是組合多個AnimatorSet和ObjectAnimator形成一個動畫,並可以控制動畫的播放順序,其中還有個輔助類通過調用play函數獲得。
3. AnimatorUpdateListner介紹
通過實現AnimatorUpdateListner,來獲得屬性值發生變化時的事件,在這個回調中發起重繪屏幕事件。
四、 使用實例
在Android4.0中的ApiDemo中有個BouncingBalls實例,描述了Animator框架的使用,當點擊屏幕時,繪制一個球從點擊位置掉到屏幕底部,碰到底部時球有壓扁的效果,然後回彈到點擊位置再消失。
代碼如下:
ShapeHolder newBall =addBall(event.getX(), event.getY());
// Bouncing animation with squash and stretch
float startY = newBall.getY();
float endY = getHeight() - 50f;
float h = (float)getHeight();
float eventY = event.getY();
int ration = (int)(500 * ((h - eventY)/h));
ValueAnimator bounceAnim = ObjectAnimator.ofFloat(newBall, "y", startY, endY);
bounceAnim.setDuration(ration);
bounceAnim.setInterpolator(new AccelerateInterpolator());
ValueAnimator squashAnim1 = ObjectAnimator.ofFloat(newBall, "x", newBall.getX(),
newBall.getX() - 25f);
squashAnim1.setDuration(ration/4);
squashAnim1.setRepeatCount(1);
squashAnim1.setRepeatMode(ValueAnimator.REVERSE);
squashAnim1.setInterpolator(new DecelerateInterpolator());
ValueAnimator squashAnim2 = ObjectAnimator.ofFloat(newBall, "width", newBall.getWidth(),
newBall.getWidth() + 50);
squashAnim2.setDuration(ration/4);
squashAnim2.setRepeatCount(1);
squashAnim2.setRepeatMode(ValueAnimator.REVERSE);
squashAnim2.setInterpolator(new DecelerateInterpolator());
ValueAnimator stretchAnim1 = ObjectAnimator.ofFloat(newBall, "y", endY,
endY + 25f);
stretchAnim1.setDuration(ration/4);
stretchAnim1.setRepeatCount(1);
stretchAnim1.setInterpolator(new DecelerateInterpolator());
stretchAnim1.setRepeatMode(ValueAnimator.REVERSE);
ValueAnimator stretchAnim2 = ObjectAnimator.ofFloat(newBall, "height",
newBall.getHeight(),newBall.getHeight() - 25);
stretchAnim2.setDuration(ration/4);
stretchAnim2.setRepeatCount(1);
stretchAnim2.setInterpolator(new DecelerateInterpolator());
stretchAnim2.setRepeatMode(ValueAnimator.REVERSE);
ValueAnimator bounceBackAnim = ObjectAnimator.ofFloat(newBall, "y", endY,
startY);
bounceBackAnim.setDuration(ration);
bounceBackAnim.setInterpolator(newDecelerateInterpolator());
// Sequence the down/squash&stretch/upanimations
AnimatorSet bouncer = new AnimatorSet();
bouncer.play(bounceAnim).before(squashAnim1);
bouncer.play(squashAnim1).with(squashAnim2);
bouncer.play(squashAnim1).with(stretchAnim1);
bouncer.play(squashAnim1).with(stretchAnim2);
bouncer.play(bounceBackAnim).after(stretchAnim2);
// Fading animation - remove the ball when theanimation is done
ValueAnimator fadeAnim = ObjectAnimator.ofFloat(newBall, "alpha", 1f, 0f);
fadeAnim.setDuration(250);
fadeAnim.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animatoranimation) {
balls.remove(((ObjectAnimator)animation).getTarget());
}
});
// Sequence the two animations to play oneafter the other
AnimatorSet animatorSet = new AnimatorSet();
animatorSet.play(bouncer).before(fadeAnim);
// Start the animation
animatorSet.start();
『肆』 android中的動畫有哪幾類,它們的特點和區別是什麼
android動畫有兩類:
一種是tweened animation(漸變動畫)
一種是frame by frame(逐幀動畫)
特點:
漸變動畫是通過改變view的大小、旋轉的角度、透明度、位置來產生動畫,可以控制動畫的播放快慢以及加速度。
逐幀動畫是用一組圖片輪流繪制,產生動畫的感覺。類似於gif圖片。
區別:
漸變動畫的所有操作是通過矩陣變換對同一個物體(繪制的一個view或者圖片)進行操作產生動畫。
而逐幀動畫是多個物體(多張圖片)進行繪制,可以說這多張圖片是不相關的(從播放的角度來看只能說是內容相關)。
『伍』 android轉場動畫windowAnimation和ActivityAnimation的區別
android轉場動畫windowAnimation和ActivityAnimation的區別顯而易見,window與Activity本身從名字上就知道不同,但對於項目開發中 windowAnimation和ActivityAnimation的區別必須心領神會。區搜索別主要如下1.windowAnimation包括 windowEnterAnimation 和 windowExitAnimation ;ActivityAnimation包含 android:activityOpenEnterAnimation , android:activityOpenExitAnimation , android:activityCloseEnterAnimation 和 android:activityCloseExitAnimation2.在項目中WindowAnimation的控制權大於Activity的控制權,即在Activity轉場過程中,如果同時設置了WindowAnimation和ActivityAnimation,那麼 可能(因為這種情況非常多) 只會執行WindowAnimation3.對於WindowAnimation的定義很簡單,在style.xml文件中只需要繼承Animation Style即可<style name="Animation" parent="@android:style/Animation"><!--窗體進入動畫--><item name="android:windowEnterAnimation">@anim/slide_left_enter</item><!--窗體退出動畫--><item name="android:windowExitAnimation">@anim/slide_right_exit</item></style>對於Activity,需要繼承Animation Activity Style<style name="FeelyouWindowAnimTheme" parent="@android:style/Animation.Activity"><item name="android:activityOpenEnterAnimation">@android:anim/slide_in_left</item><item name="android:activityOpenExitAnimation">@android:anim/slide_out_right</item><item name="android:activityCloseEnterAnimation">@anim/push_right_in</item><item name="android:activityCloseExitAnimation">@anim/push_left_out</item></style>當自己從 A1 啟動 A2 時,A1 從屏幕上消失,這個動畫叫做 android:activityOpenExitAnimation當自己從 A1 啟動 A2 時,A2 出現在屏幕上,這個動畫叫做 android:activityOpenEnterAnimation當自己從 A2 退出回到 A1 時,A2 從屏幕上消失,這個叫做 android:activityCloseExitAnimation當自己從 A2 退出回到 A1 時,A1 出現在屏幕上,這個叫做 android:activityCloseEnterAnimation從上述2中動畫的定義上來看,顯然ActivityAnimation更為復雜,但這種復雜帶來的轉場效果非常好,可以同時控制2個Activity的動畫,而不像WindowAnimation只能控制下一個Activity的窗體動畫。5.在開發中,窗體動畫也可以使用 Activity. overridePendingTransition來設置,也可以定義在主題中,但Activity只能使用在主題中<applicationandroid:name="test.view.weitop.BaseApplication"android:allowBackup="false"android:hardwareAccelerated="false"android:icon="@drawable/app_logo"android:label="@string/app_name"android:largeHeap="true"android:theme="@style/Theme.App" ></application>6.對於比較追求界面美感的動畫,使用ActivityAnimation要好得多,因此對於一般開發使用windowAnimation即可,但對於追求用戶體驗,那麼直接使用Activity Animation 吧
『陸』 android中的動畫有哪幾類
在Android3.0(即API Level11)以前,Android僅支持2種動畫:分別是Frame Animation(逐幀動畫)和Tween Animation(補間動畫),在3.0之後Android支持了一種新的動畫系統,稱為:Property Animation(屬性動畫)。
一、Frame Animation:(逐幀動畫)
這個很好理解,一幀幀的播放圖片,利用人眼視覺殘留原理,給我們帶來動畫的感覺。它的原理的GIF圖片、電影播放原理一樣。
1.定義逐幀動畫比較簡單,只要在中使用子元素定義所有播放幀即可。
(1) android:oneshot 設置是否僅播放一次
(2) android:drawable 設置每一幀圖片
(3) android:ration 設置圖片間切換間隔
2.習慣上把AnimationDrawable設置為ImageView的背景
android:background=@anim/frame_anim
然後我們就可以在java代碼中獲取AnimationDrawable對象了
AnimationDrawable anim = (AnimationDrawable)imageView.getBackground();
(需要注意的是,AnimationDrawable默認是不播放的,調用其start()方法開始播放,stop停止播放)
3.上面的動畫文件是通過xml文件來配置的,如果你喜歡,也可以通過在java代碼中創建AnimationDrawable對象,然後通過addFrame(Drawable frame, int ration)方法向動畫添加幀,然後start()。。。
二、Tween Animation:(補間動畫)
補間動畫就是我們只需指定開始、結束的「關鍵幀「,而變化中的其他幀由系統來計算,不必自己一幀幀的去定義。
1. Android使用Animation代表抽象動畫,包括四種子類:AlphaAnimation(透明度動畫)、ScaleAnimation(縮放動畫)、TranslateAnimation(位移動畫)、RotateAnimation(透明度動畫)。Android裡面允許在java中創建Animation類對象,但是一般都會採用動畫資源文件來定義動畫,把界面與邏輯分離
<set android:interpolator="@android:anim/linear_interpolator" xmlns:android="http://schemas.android.com/apk/res/android">
<!-- 定義透明度的變換 -->
<!-- 定義旋轉變換 -->
<rotate android:ration="3000/" android:fromdegrees="0" android:pivotx="50%" android:pivoty="50%" android:todegrees="1800">
</rotate></alpha></set>
(一個set可以同時定義多個動畫,一起執行。)
2. android:interpolator=@android:anim/linear_interpolator控制動畫期間需要補入多少幀,簡單來說就是控制動畫速度,有些地方翻譯為「插值「。Interpolator有幾種實現類:LinearInterpolator、AccelerateInterpolator、、CycleInterpolator、DecelerateInterpolator,具體使用可以參考官方API Demo。
3. 定義好anim文件後,我們可以通過AnimationUtils工具類來載入它們,載入成功後返回一個Animation。然後就可以通過View的startAnimation(anim)開始執行動畫了。
Animation anim = AnimationUtils.loadAnimation(this, R.anim.anim);
//設置動畫結束後保留結束狀態
anim.setFillAfter(true);
//設置插值效果
anim.setInterpolator(interpolator);
//對view執行動畫
view. startAnimation(anim);
三、Property Animation:(屬性動畫)
屬性動畫,這個是在Android 3.0中才引進的,它可以直接更改我們對象的屬性。在上面提到的Tween Animation中,只是更改View的繪畫效果而View的真實屬性是不改變的。假設你用Tween動畫將一個Button從左邊移到右邊,無論你怎麼點擊移動後的Button,他都沒有反應。而當你點擊移動前Button的位置時才有反應,因為Button的位置屬性木有改變。而Property Animation則可以直接改變View對象的屬性值,這樣可以讓我們少做一些處理工作,提高效率與代碼的可讀性。
(1)ValueAnimator:包含Property Animation動畫的所有核心功能,如動畫時間,開始、結束屬性值,相應時間屬性值計算方法等。應用ValueAnimator有兩個步驟
1計算屬性值。
2根據屬性值執行相應的動作,如改變對象的某一屬性。
我們的主是第二步,需要實現ValueAnimator.onUpdateListener介面,這個介面只有一個函數onAnimationUpdate(),將要改變View對象屬性的事情在該介面中do。
animation.addUpdateListener(new AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
//do your work
}
});
(2)ObjectAnimator:繼承自ValueAnimator,要指定一個對象及該對象的一個屬性,當屬性值計算完成時自動設置為該對象的相應屬性,即完成了Property Animation的全部兩步操作。實際應用中一般都會用ObjectAnimator來改變某一對象的某一屬性,但用ObjectAnimator有一定的限制,要想使用ObjectAnimator,應該滿足以下條件:
1.對象應該有一個setter函數:set(駝峰命名法)
2如下面的例子,像ofFloat之類的工場方法,第一個參數為對象名,第二個為屬性名,後面的參數為可變參數,如果values…參數只設置了一個值的話,那麼會假定為目的值,屬性值的變化范圍為當前值到目的值,為了獲得當前值,該對象要有相應屬性的getter方法:get
3如果有getter方法,其應返回值類型應與相應的setter方法的參數類型一致。
ObjectAnimator oa=ObjectAnimator.ofFloat(tv, alpha, 0f, 1f);
oa.setDuration(3000);
oa.start();
如果不滿足上面的條件,我們只能乖乖的使用ValueAnimator來創建動畫。
(3)Animator.AnimatorListener:可以為Animator設置動畫監聽,需要重寫下面四個方法。
onAnimationStart()
onAnimationEnd()
onAnimationRepeat()
onAnimationCancel()
這里我們也可以實現AnimatorListenerAdapter,他的好處是可以只用定義想監聽的事件而不用實現每個函數卻只定義一空函數體。如下:
anim.addListener(new AnimatorListenerAdapter() {
public void on AnimationEnd(Animator animation){
//do your work
}
});
(4)AnimationSet:可以組合多個動畫共同工作
AnimatorSet bouncer = new AnimatorSet();
bouncer.play(anim1).before(anim2);
bouncer.play(anim2).with(anim3);
bouncer.play(anim2).with(anim4)
bouncer.play(anim5).after(amin2);
animatorSet.start();
上面的代碼意思是: 首先播放anim1;同時播放anim2,anim3,anim4;最後播放anim5。
(5)TimeInterplator:與Tween中的interpolator類似。有以下幾種
AccelerateInterpolator 加速,開始時慢中間加速
DecelerateInterpolator 減速,開始時快然後減速
先加速後減速,開始結束時慢,中間加速
AnticipateInterpolator 反向 ,先向相反方向改變一段再加速播放
反向加回彈,先向相反方向改變,再加速播放,會超出目的值然後緩慢移動至目的值
BounceInterpolator 跳躍,快到目的值時值會跳躍,如目的值100,後面的值可能依次為85,77,70,80,90,100
CycleIinterpolator 循環,動畫循環一定次數,值的改變為一正弦函數:Math.sin(2 * mCycles * Math.PI * input)
LinearInterpolator 線性,線性均勻改變
OvershottInterpolator 回彈,最後超出目的值然後緩慢改變到目的值
TimeInterpolator 一個介面,允許你自定義interpolator,以上幾個都是實現了這個介面
(6)Keyframes:可以讓我們定義除了開始和結束以外的關鍵幀。KeyFrame是抽象類,要通過ofInt(),ofFloat(),ofObject()獲得適當的KeyFrame,然後通過PropertyValuesHolder.ofKeyframe獲得PropertyValuesHolder對象,如下:
Keyframe kf0 = Keyframe.ofInt(0, 400);
Keyframe kf1 = Keyframe.ofInt(0.25f, 200);
Keyframe kf2 = Keyframe.ofInt(0.5f, 400);
Keyframe kf4 = Keyframe.ofInt(0.75f, 100);
Keyframe kf3 = Keyframe.ofInt(1f, 500);
PropertyValuesHolder pvhRotation = PropertyValuesHolder.ofKeyframe(width, kf0, kf1, kf2, kf4, kf3);
ObjectAnimator rotationAnim = ObjectAnimator.ofPropertyValuesHolder(btn, pvhRotation);
上述代碼的意思是:設置btn對象的width屬性值使其:開始時 Width=400,動畫開始1/4時 Width=200,動畫開始1/2時 Width=400,動畫開始3/4時 Width=100,動畫結束時 Width=500。
(7)ViewPropertyAnimator:對一個View同時改變多種屬性,非常推薦用這種。該類對多屬性動畫進行了優化,會合並一些invalidate()來減少刷新視圖。而且使用起來非常簡便,但是要求API LEVEL 12,即Android 3.1以上。僅需要一行代碼即可完成水平、豎直移動
myView.animate().translationX(50f). translationY(100f);
(8)常需要改變的一些屬性:
translationX,translationY: View相對於原始位置的偏移量
rotation,rotationX,rotationY: 旋轉,rotation用於2D旋轉角度,3D中用到後兩個
scaleX,scaleY: 縮放比
x,y: View的最終坐標,是View的left,top位置加上translationX,translationY
alpha: 透明度
四、最後自己總結一下這三種動畫的優缺點:
(1)Frame Animation(幀動畫)主要用於播放一幀幀准備好的圖片,類似GIF圖片,優點是使用簡單方便、缺點是需要事先准備好每一幀圖片;
(2)Tween Animation(補間動畫)僅需定義開始與結束的關鍵幀,而變化的中間幀由系統補上,優點是不用准備每一幀,缺點是只改變了對象繪制,而沒有改變View本身屬性。因此如果改變了按鈕的位置,還是需要點擊原來按鈕所在位置才有效。
(3)Property Animation(屬性動畫)是3.0後推出的動畫,優點是使用簡單、降低實現的復雜度、直接更改對象的屬性、幾乎可適用於任何對象而僅非View類,缺點是需要3.0以上的API支持,限制較大!但是目前國外有個開源庫,可以提供低版本支持!
『柒』 android兩個animation無限循環怎麼做
據我所知,想直接給AnimationSet設置重復,是不行的。不過你可以這樣來:
final int transDuration = 2000;
final int alphaDuration = 1000;
AnimationSet set = new AnimationSet(false);
set.setRepeatMode(Animation.RESTART);
TranslateAnimation translateAnimation = new TranslateAnimation(0, 0, 0, 300);
translateAnimation.setInterpolator(new Interpolator() {
@Override
public float getInterpolation(float arg0) {
float ret = arg0 / (1.0f * transDuration / (transDuration + alphaDuration));
return ret < 1 ? ret : 1;
}
});
translateAnimation.setRepeatCount(Animation.INFINITE);
translateAnimation.setDuration(transDuration + alphaDuration);
AlphaAnimation alphaAnimation = new AlphaAnimation(1, 0);
alphaAnimation.setRepeatCount(Animation.INFINITE);
alphaAnimation.setDuration(alphaDuration);
alphaAnimation.setStartOffset(transDuration);
set.addAnimation(translateAnimation);
set.addAnimation(alphaAnimation);
view.startAnimation(set);
或者像其他所說的,通過在一個動畫結束後開始另外一個動畫的方式。
『捌』 如何高效學習Android動畫
可以給題主一些概述,具體的細節可以根據你的實際需求或者感興趣的方面再慢慢展開,每個部分都能挖掘出很有趣的內容:
關於在實際工作中常用或者會接觸到的 Android Animation 大概可以分成以下幾種:
1. View Animation
這種屬於最常使用的動畫之一,例如 View Slide, Fade In/Out, Parallax Effect 等等
2. Activity Transition
常見於 Activity 進入或者跳出時的動畫,比如啟動一個 Activity, 從側面滑入。在 Android 4.4 之後,引入了Scene, enterTransition 和 exitTransition 等概念,可以定義 Activity 進入以後不同View 做的一系列動畫。在 Android 5.0 以後引入了 ShareElementsTransition, 讓開發高質量的 Activity Transition 變的更加容易。
3. Drawable Animation
Drawable Animation 常見於啟動或者一些載入過程中的幀動畫。當然,Android 5.0 以後引入了 Vector Drawable, 一些很漂亮的 icon transition 就變的相對很容易實現一些,自然應用細節體驗就能上很大一個台階。
4. Property Animation
Property Animation 是 Android 3.0 以後引入的動畫框架,一開始概念略微難理解,但是理解以後會發現非常好用,很多自定義動畫或者復雜動畫的場景變換可以藉助這套框架來實現。
5. 其他
這些包括 @徐廷霆 提到的粒子,分形,煙霧,模糊等等,需要藉助一些高階技術,比如 RenderScript, OpenGLES, NDK 等等來做,假如不是特別需求,一般開發應用過程中還不會用到,做為興趣愛好倒是挺好的一個切入點。
『玖』 Android 中的動畫有哪幾類,它們的特點和區別是什麼
1.View Animation(Tween Animation):補間動畫,給出兩個關鍵幀,通過一些演算法將給定屬性值在給定的時間內在兩個關鍵幀間漸變。
View animation只能應用於View對象,而且只支持一部分屬性,這種實現方式可以使視圖組件移動、放大、縮小以及產生透明度的變化.
2.Frame動畫,傳統的動畫方法,通過順序的播放排列好的圖片來實現,類似電影補間動畫和幀動畫。
補間動畫和Frame動畫的定義:
所謂補間動畫,是指通過指定View的初末狀態和變化時間、方式,對View的內容完成一系列的圖形變換來實現動畫效果。主要包括四種效果:Alpha、Scale、Translate和Rotate。
幀動畫就是Frame動畫,即指定每一幀的內容和停留時間,然後播放動畫。。
3.屬性動畫
只是一個動畫效果,組件其實還在原來的位置上,xy沒有改變
###位移:
第一個參數target指定要顯示動畫的組件
第二個參數propertyName指定要改變組件的哪個屬性
第三個參數values是可變參數,就是賦予屬性的新的值
傳入0,代表x起始坐標:當前x + 0
傳入100,代表x終點坐標:當前x + 100
//具有get、set方法的成員變數就稱為屬性
ObjectAnimator oa = ObjectAnimator.ofFloat(bt, "translationX", 0, 100) ;
4.四種基本的動畫 ,透明/伸縮/移動/旋轉。
(1)XML中
alpha 漸變透明度動畫效果
scale 漸變尺寸伸縮動畫效果
translate畫面轉換位置移動動畫效果
rotate畫面轉移旋轉動畫效果
(2) JavaCode中
AlphaAnimation漸變透明度動畫效果
ScaleAnimation漸變尺寸伸縮動畫效果
TranslateAnimation畫面轉換位置移動動畫效果
RotateAnimation畫面轉移旋轉動畫效果
(3)Android動畫模式
Animation主要有兩種動畫模式:
一種是tweened animation(漸變動畫)
一種是frame by frame(畫面轉換動畫)
Tween動畫,這種實現方式可以使視圖組件移動、放大、縮小以及產生透明度的變化;
Frame動畫,傳統的動畫方法,通過順序的播放排列好的圖片來實現,類似電影。