Android APP启动界面(动画)

首先定义基类BaseActivity

public abstract class BaseActivity extends AppCompatActivity {

实现类SplashActivity

public class SplashActivity extends BaseActivity {
    @BindView(R.id.iv_logo)
    ImageView mIvLogo;
    @BindView(R.id.tv_name)
    TextView mTvName;

    @Override
    public int getLayoutId() {
        return R.layout.activty_splash;
    }

    @Override
    public void initPresenter() {

    }

    @Override
    public void initView() {
        ............
        });
        animatorSet.start();
    }

}

**

知识点:

**
1. Android 注解式绑定控件BindView

    @BindView(R.id.iv_logo)
    ImageView mIvLogo;
    @BindView(R.id.tv_name)
    TextView mTvName;

2.属性动画 PropertyValuesHolder类(存储动画属性和值,执行,降低代码量)

PropertyValuesHolder alpha = PropertyValuesHolder.ofFloat("alpha", 0.3f, 1f);
        PropertyValuesHolder scaleX = PropertyValuesHolder.ofFloat("scaleX", 0.3f, 1f);
        PropertyValuesHolder scaleY = PropertyValuesHolder.ofFloat("scaleY", 0.3f, 1f);
        ObjectAnimator objectAnimator1 = ObjectAnimator.ofPropertyValuesHolder(mTvName, alpha, scaleX, scaleY);
        ObjectAnimator objectAnimator2 = ObjectAnimator.ofPropertyValuesHolder(mIvLogo, alpha, scaleX, scaleY);

3.AnimatorSet类

AnimatorSet animatorSet = new AnimatorSet();
        animatorSet.playTogether(objectAnimator1, objectAnimator2);
        animatorSet.setInterpolator(new AccelerateInterpolator());
        animatorSet.setDuration(2000);
        animatorSet.addListener(new Animator.AnimatorListener() {
            @Override
            public void onAnimationStart(Animator animator) {

            }

            @Override
            public void onAnimationEnd(Animator animator) {
            MainActivity.startAction(SplashActivity .this);
                finish();
            }

你可能感兴趣的:(android基础知识)