[英]Lottie Animation in Native Android Splash Screen
Is it possible to load a Lottie animation in the layout of my splash screen?是否可以在我的初始屏幕布局中加载 Lottie animation?
Currently my splash screen layout is as such:目前我的启动画面布局是这样的:
background.xml背景.xml
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"
android:opacity="opaque">
<item android:drawable="@drawable/path_background_gradient" />
<item
android:drawable="@drawable/ic_locky"
android:gravity="center" />
</layer-list>
styles.xml styles.xml
<!-- Splash Launcher UI theme. -->
<style name="Locky.Theme.Launcher" parent="Locky.Theme">
<item name="android:windowBackground">@drawable/custom_background_launcher</item>
<item name="colorPrimary">@color/background_gradient_accent_start</item>
<item name="colorPrimaryDark">@color/background_gradient_accent_start</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
I used this to prevent the white screen on android cold boot.我用它来防止 android 冷启动时出现白屏。
But instead of the icon ic_locky
I want to use a Lottie animation.但我想使用 Lottie animation 而不是图标
ic_locky
。 Is it possible to do so?有可能这样做吗? Because there are many apps that uses an animated logo in the splash screen.
因为有许多应用程序在启动画面中使用动画徽标。
Since there is litte control over WindowManager you can use a static image of your animation in windowbackground and then replace it with the lottie animation.由于对 WindowManager 的控制很少,因此您可以在 windowbackground 中使用 animation 的 static 图像,然后将其替换为 lottie animation。
Lottie:洛蒂:
implementation 'com.airbnb.android:lottie:$lottieVersion'
highest version seems to be 3.4.0 at this time.目前最高版本似乎是 3.4.0。
And then use the LottieAnimationView to load the animation:然后使用 LottieAnimationView 加载 animation:
<com.airbnb.lottie.LottieAnimationView
android:id="@+id/lav_thumbUp"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_marginStart="80dp"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:lottie_autoPlay="false"
app:lottie_fileName="thumb_up.json"
app:lottie_loop="false"
app:lottie_speed="1.25" />
Read more: https://github.com/airbnb/lottie-android/blob/master/README.md阅读更多: https://github.com/airbnb/lottie-android/blob/master/README.md
@Mervin Hemaraju... @Mervin Hemaraju...
I think you ca do so, but, instead of using a drawable, use a custom layout / activity for the splash screen.我认为您可以这样做,但是不要使用可绘制对象,而是使用自定义布局/活动作为启动屏幕。
(1) Read this for the detail: https://android.jlelse.eu/the-complete-android-splash-screen-guide-c7db82bce565 (1) 详细阅读: https://android.jlelse.eu/the-complete-android-splash-screen-guide-c7db82bce565
(2) Check the related section Using a Launcher Theme with a Dedicated Splash Activity (2) 检查相关部分Using a Launcher Theme with a Dedicated Splash Activity
Best Regards,此致,
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.