【转载】【Android】Splash animation effect

实现:
1.build.gradle中添加库

implementation 'com.airbnb.android:lottie:3.4.1'

2.将图片放到drawable目录下:
将动态json文件放到app\src\main\res\raw目录下
3.在布局文件中添加如下:

    <ImageView
        android:id="@+id/img"
        android:layout_width="wrap_content"
        android:layout_height="900dp"
        android:scaleType="centerCrop"
        android:src="@drawable/bg"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintBottom_toBottomOf="parent"/>

    <ImageView
        android:id="@+id/app_name"
        android:layout_width="300dp"
        android:layout_height="wrap_content"
        android:src="@drawable/app_name"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.495"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_bias="0.181" />

    <com.airbnb.lottie.LottieAnimationView
        android:id="@+id/lottie"
        android:layout_width="wrap_content"
        android:layout_height="300dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:lottie_autoPlay="true"
        app:lottie_rawRes="@raw/splash" />

4:在Java中添加如下:

splashimg.animate().translationY(-2500).setDuration(1000).setStartDelay(5000);
appname.animate().translationY(2000).setDuration(1000).setStartDelay(5000);
lottieAnimationView.animate().translationY(1500).setDuration(1000).setStartDelay(5000);

        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                startActivity(new Intent(splash.this,MainActivity.class));
				finish();
            }
        },6000);

参考连接:
https://lottiefiles.com/
https://github.com/foxandroid/Splashscreenanimation
https://www.youtube.com/watch?v=Amg4JKylQlw

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值