旋转动画实现
2018-04-28 本文已影响0人
跟我去北方吧
ImageView loading = (ImageView) findViewById(R.id.iv_pre_loading);
private void showRotate() {
Animation mRotateAnimation = new RotateAnimation(0.0f, 720.0f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
mRotateAnimation.setFillAfter(true);
mRotateAnimation.setInterpolator(new LinearInterpolator());
mRotateAnimation.setDuration(1200);
mRotateAnimation.setRepeatCount(Animation.INFINITE);
mRotateAnimation.setRepeatMode(Animation.RESTART);
loading.setVisibility(View.VISIBLE);
//设置为半透明
loading.setAlpha(0.5f);
loading.setAnimation(mRotateAnimation);
}
private void stopRotate() {
loading.setAnimation(null);
loading.setVisibility(View.GONE);
}