andorid 動畫RotateAnimation的使用...




















package com.test;
import android.app.Activity;
import android.graphics.drawable.AnimationDrawable;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.animation.AccelerateDecelerateInterpolator;
import android.view.animation.Animation;
import android.view.animation.RotateAnimation;
import android.widget.Button;
import android.widget.ImageView;

public class DrawActivity extends Activity implements OnClickListener {
    /** Called when the activity is first created. */
   
    private ImageView img1;

   
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
            
        ImageView btn = (ImageView) findViewById(R.id.img1);
       
       btn.setOnClickListener(this);  
       
    }

    @Override
    public void onClick(View v) {
        Animation anim = null; 
        anim = new RotateAnimation(0.0f,+360.0f); 
        anim.setInterpolator(new AccelerateDecelerateInterpolator()); 
        anim.setDuration(3000); 
        findViewById(R.id.img1).startAnimation(anim);
    }
 
}



說明:建構子有四個:Public Constructors
,我們這次使用的是第二種.
  • RotateAnimation(Context context, AttributeSet attrs)
Constructor used when a RotateAnimation is loaded from a resource.
  • RotateAnimation(float fromDegrees, float toDegrees)
Constructor to use when building a RotateAnimation from code.
  • RotateAnimation(float fromDegrees, float toDegrees, float pivotX, float pivotY)
Constructor to use when building a RotateAnimation from code
  • RotateAnimation(float fromDegrees, float toDegrees, int pivotXType, float pivotXValue, int pivotYType, float pivotYValue)
Constructor to use when building a RotateAnimation from code

留言

這個網誌中的熱門文章

最爛的銀行服務-玉山銀行

Mark App Design Apps - Terms and Privacy Policy (服務條款,隱私權政策)

SMR疊瓦式hdd致命缺陷被解決????!!!

ios app 上架時app icon要注意事項

更改google drive預設存放目錄位置Change Google Drive Default Folder Location in Windows

google play 正式發布前測試報告...非常好用.

舊有app在Android 12 閃退問題& app Splash screens

app bundle and bundletool. 關於aab安裝問題

關於google play console app應用程式簽署

Google Play badge徽章產生器