animshake.java

来自「android anim simple demo」· Java 代码 · 共 54 行

JAVA
54
字号
package iii.org;import iii.org.anim3DTransition.DisplayNextView;import android.app.Activity;import android.graphics.Bitmap;import android.graphics.BitmapFactory;import android.os.Bundle;import android.view.View;import android.view.animation.AccelerateInterpolator;import android.view.animation.Animation;import android.view.animation.AnimationUtils;import android.widget.ImageView;public class animShake extends Activity implements View.OnClickListener {    /** Called when the activity is first created. *///    @Override//    public void onCreate(Bundle savedInstanceState) {//        super.onCreate(savedInstanceState);//        setContentView(R.layout.main);//    }    @Override    public void onCreate(Bundle savedInstanceState) {    	        super.onCreate(savedInstanceState);        setContentView(R.layout.animation_1);        View loginButton = findViewById(R.id.login);        loginButton.setOnClickListener(this);    }    public void onClick(View v) {        Animation shake = AnimationUtils.loadAnimation(this, R.anim.shake);        findViewById(R.id.iv).startAnimation(shake);    }        private void applyRotation(int position, float start, float end) {    	// Find the center of the container    	final float centerX = mContainer.getWidth() / 2.0f;    	final float centerY = mContainer.getHeight() / 2.0f;    	// Create a new 3D rotation with the supplied parameter    	// The animation listener is used to trigger the next animation    	final Rotate3dAnimation rotation =    	        new Rotate3dAnimation(start, end, centerX, centerY, 310.0f, true);  //310.0f    	rotation.setDuration(500);    	rotation.setFillAfter(true);    	rotation.setInterpolator(new AccelerateInterpolator());    	rotation.setAnimationListener(new DisplayNextView(position));    	mContainer.startAnimation(rotation);    	}}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?