动画效果的实现代码

一、在res文件中创建animal

<set xmlns:android="http://schemas.android.com/apk/res/android" android:duration="5000">
<rotate android:fromDegrees="0" android:toDegrees="360" />
</set>

二、在Activity的Xml中随便创建一个ImageView即可

<ImageView
    android:id="@+id/mImage"
    android:background="@mipmap/ic_launcher"
    android:layout_width="200dp"
    android:layout_height="200dp" />

三、在Activity中在initView()方法中

Animation animation = AnimationUtils.loadAnimation(this, R.anim.animo);
//给图片设置动画
    mImage.setAnimation(animation);
//开启动画
    animation.start();
    animation.setAnimationListener(new Animation.AnimationListener() {
    @Override
    public void onAnimationStart(Animation animation) {

    }

    @Override
    public void onAnimationEnd(Animation animation) {
        Intent intent = new Intent(MainActivity.this, MainActivity2.class);
        startActivity(intent);
    }

    @Override
    public void onAnimationRepeat(Animation animation) {

    }
});

四、学习一下动画当中需要用到的单词,具体实现不同的效果:

动画:
    alpha          透明度 0.0--1.0
    translate     位移  1dp --100dp
    scale           缩放  0.5--5.0
    rotate          旋转 0 ---360
    set              集合  

shape:
    corners        弧度
    stroke          描边
    gradient       对应颜色渐变
    padding       定义内容离边界的距离、内边距
    size             尺寸
    solid           填充、线条
    

猜你喜欢

转载自blog.csdn.net/qq_42749901/article/details/81157521