package com.bwie.android.day03_app;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.support.v7.app.AppCompatActivity;
import android.view.animation.Animation;
import android.view.animation.LinearInterpolator;
import android.view.animation.RotateAnimation;
import android.widget.ImageView;
import android.widget.TextView;
public class MainActivity extends AppCompatActivity {
private int time;
private TextView timeText;
private Handler handler = new Handler() {
@Override
public void handleMessage(Message msg) {
super.handleMessage(msg);
if (time <= 0) {
startActivity(new Intent(MainActivity.this, HomePagerActivity.class));
finish();
return;
}
time--;
timeText.setText(time + "s");
handler.sendEmptyMessageDelayed(1, 1000);
}
};
private ImageView img;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
timeText = findViewById(R.id.textView);
img = findViewById(R.id.imageView);
time = 2;
timeText.setText(time + "s");
handler.sendEmptyMessageDelayed(1, 1000);
RotateAnimation rotate = new RotateAnimation(0f, 360f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
/*设置插入器
* 动画从开始到结束,变化率是线性变化。*/
LinearInterpolator lin = new LinearInterpolator();
rotate.setInterpolator(lin);
rotate.setDuration(2000);//设置动画持续周期
rotate.setRepeatCount(Animation.INFINITE);//设置重复次数
rotate.setFillAfter(true);//动画执行完后是否停留在执行完的状态
img.setAnimation(rotate);
}
}
中点旋转动画 延时跳转
最新推荐文章于 2019-11-08 12:14:53 发布