做動畫,你需要創建在res文件夾中的文件夾「動畫」,並添加這樣一個XML文件:在您的Java類的嘗試
<?xml version="1.0" encoding="UTF-8"?>
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
android:fromDegrees="0"
android:toDegrees="360"
android:pivotX="50%"
android:pivotY="50%"
android:duration="1000"/>
:
Animation a = AnimationUtils.loadAnimation(this, R.anim.yourAnim);
a.setAnimationListener(new AnimationListener()
{
@Override
public void onAnimationEnd(Animation animation)
{
animPlaying = false;
}
@Override
public void onAnimationStart(Animation animation)
{
animPlaying = true;
}
@Override
public void onAnimationRepeat(Animation animation){}
});
public boolean onTouch(View v, MotionEvent event)
{
int n = 0;
postInvalidate();
if(aninmPlaying == false)
{
yourView.startAnimation(a);
}
forceLayout();
觸摸後纔開始動畫並不容易嗎? – goodm 2012-03-28 09:41:54
thanx的評論,但我怎麼能讓這樣的動畫? – user1297720 2012-03-28 09:49:38