既然你只使用1個動畫,你不需要使用<set>
。集合用於多個動畫。 試試這個:
<alpha xmlns:android="http://schemas.android.com/apk/res/android"
android:fromAlpha="0"
android:toAlpha="1"
android:duration="2000" />
,並在您的活動:
Animation newsAnim= AnimationUtils.loadAnimation(this, R.anim.news_animation);
newsAnim.reset(); // reset initialization state
newsAnim.setRepeatMode(Animation.RESTART);
newsAnim.setRepeatCount(Animation.INFINITE); // Or a number of times
TextView animatedText = (TextView) findViewById(R.id.lbl_animated);
animatedText.startAnimation(newsAnim);
這將調用你的動畫,設置所需的時間/功能。 我已經注意到,循環動畫的設置並不像這樣容易。
編輯:如果你需要使用一個<set>
明確,那麼你就可以做到以下幾點:
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate
android:fromXDelta="0%" android:toXDelta="0%"
android:fromYDelta="100%" android:toYDelta="-100%"
android:duration="15000" android:zAdjustment="bottom"
android:repeatMode="restart"
android:repeatCount="-1" />
<scale
android:fromXScale="4" android:toXScale="1"
android:fromYScale="3" android:toYScale="1"
android:pivotX="50%" android:pivotY="50%"
android:duration="15000"
android:repeatMode="restart"
android:repeatCount="-1" />
</set>
注意所有的動畫的持續時間。如果你想要一致的動畫,讓它們保持一致。
希望這有助於。 您確定,
Nyllian
謝謝。問題是我正在嘗試對appwidget進行動畫製作,而不是常規活動,因此我無權訪問AnimationUtils。 – 2012-02-19 13:21:19