1
我有一個三角形,每次用戶點擊屏幕時我都想旋轉120度。我有三個旋轉動畫,從0-120,120-240和240-360度。Android旋轉動畫
旋轉1:
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/linear_interpolator"
android:fillAfter="true">
<rotate
android:duration="500"
android:pivotX="50%"
android:pivotY="50%"
android:repeatCount="0"
android:startOffset="0"
android:fromDegrees="0"
android:toDegrees="120"
/>
</set>
在我的MainActivity的網頁我有:
import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MotionEvent;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
public class StartPage2 extends Activity {
Animation rotate1;
Animation rotate2;
Animation rotate3;
View triangle2;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.start_page_two);
rotate1 = AnimationUtils.loadAnimation(this, R.anim.rotate1);
rotate2 = AnimationUtils.loadAnimation(this, R.anim.rotate2);
rotate3 = AnimationUtils.loadAnimation(this, R.anim.rotate3);
triangle2 = (View) findViewById(R.id.triangle2);
}
public boolean onTouchEvent(MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_DOWN) {
triangle2.startAnimation(rotate2);
return true;
}
return super.onTouchEvent(event);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_main, menu);
return true;
}
}
和那麼,你的問題是什麼? –