- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我在 After Effects 中制作了启动画面 Logo 的动画,希望我只将 LottieAnimationView 添加到 native 启动画面的背景层列表,但它不起作用。
我不想要带有计时器的虚假启动画面。我真的只是想在应用程序初始化时显示这个动画,所以我没有为此创建 Flutter 小部件。
Lottie 动画如何显示在图层列表中?是否可以?是否可以在不需要 Android View 的情况下完成(因为我真的从来没有搞砸过它)?
这是我尝试过的:
<item>
<com.airbnb.lottie.LottieAnimationView
android:id="@+id/animation_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:lottie_fileName="logo.json"
app:lottie_loop="true"
app:lottie_autoPlay="true" />
</item>
最佳答案
AbedElaziz Shehadeh explained how to do this on Medium 2020 年 12 月 8 日:
Start by adding Lottie dependency to your project's
build.gradle
file found at /android/app/ (I added constraint layout dependency aswell).dependencies {
...
implementation "com.airbnb.android:lottie:3.5.0"
implementation "com.android.support.constraint:constraint-layout:2.0.4"
...
}In
AndroidManifest.xml
remove meta data tag with the nameio.flutter.embedding.android.SplashScreenDrawable
and replaceLaunchTheme
under activity tag withNormalTheme
so your file will look like the following:<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.abedelazizshe.flutter_lottie_splash_app">
<!-- io.flutter.app.FlutterApplication is an android.app.Application that calls FlutterMain.startInitialization(this); in its onCreate method. In most cases you can leave this as-is, but you if you want to provide additional functionality it is fine to subclass or reimplement FlutterApplication and put your custom class here. -->
<application
android:name="io.flutter.app.FlutterApplication"
android:label="flutter_lottie_splash_app"
android:icon="@mipmap/ic_launcher">
<activity
android:name=".MainActivity"
android:launchMode="singleTop"
android:theme="@style/NormalTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize">
<!-- Specifies an Android theme to apply to this Activity as soon as the Android process has started. This theme is visible to the user while the Flutter UI initializes. After that, this theme continues to determine the Window background behind the Flutter UI. -->
<meta-data
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="@style/NormalTheme"
/>
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<!-- Don't delete the meta-data below.
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
<meta-data
android:name="flutterEmbedding"
android:value="2" />
</application>
</manifest>You can remove
LaunchTheme
from /android/app/res/values/styles.xml asyou will not need it any more.Create a
raw
directory under /android/app/res/values and copy the .json file, whether you created your own or downloaded a free sample from the link above. In this tutorial, it’s namedsplash_screen.json
.In order to use the .json file and display the animation view, we need to create a splash view class with its layout. Under /android/app/res, create a new directory called
layout
(if it does not exist) and then create a new resource file calledsplash_view.xml
. Open the XML file and ensure it looks like the following:<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.airbnb.lottie.LottieAnimationView
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:lottie_autoPlay="true"
app:lottie_rawRes="@raw/splash_screen"
app:lottie_loop="false"
app:lottie_speed="1.00" />
</androidx.constraintlayout.widget.ConstraintLayout>For this demo, I set the animation to auto play, with a speed of 1.0.And I don’t want it to loop. You can play with the different values asyou wish. The most important part is
app:lottie_rawRes
that indicateswe want to use the json file we added inraw
directory. Now, we needto create the splash view class. You can do that by going to/android/app/src/main/kotlin/YOUR-PACKAGE-NAME/ and create a newkotlin class. Call itSplashView
then ensure it looks like the following:import android.content.Context
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import io.flutter.embedding.android.SplashScreen
class SplashView : SplashScreen {
override fun createSplashView(context: Context, savedInstanceState: Bundle?): View? =
LayoutInflater.from(context).inflate(R.layout.splash_view, null, false)
override fun transitionToFlutter(onTransitionComplete: Runnable) {
onTransitionComplete.run()
}
}As you can see, this view is inflatting splash_view layout. The finalstep is to let MainActivity know about our custom splash view.
Go to /android/app/src/main/kotlin/YOUR-PACKAGE-NAME/ and click on
MainActivity.kt
. FlutterActivity provides a method calledprovideSplashScreen
and we just need to implement it as follows:import io.flutter.embedding.android.FlutterActivity
import io.flutter.embedding.android.SplashScreen
class MainActivity: FlutterActivity() {
override fun provideSplashScreen(): SplashScreen? = SplashView()
}The project directory should look like this now:
That's all for Android. Just run the app and you should see the animated screen at app launch.
关于android - 在 Flutter 应用程序中使用 Lottie 动画的原生 android 启动画面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63204650/
我想创建一个没有任何外部依赖的动画网络组件。 直到现在,当我使用 lottie 时,我提供了一个指向 lottie JSON 的路径 lottie.loadAnimation({ [...]
我无法更改我在 flutter 中设置的 lottie 动画的属性。 (我特别想改变颜色。) 根据包 README,我知道我可以使用 ValueDelegate 类来执行此操作。 README //F
该文档同时具有事件和事件监听器。我可以让 EventListeners 触发,但 Event 没有足够的文档让我开始。有什么区别以及如何使用?谢谢你。 https://github.com/airbn
我使用lottie向网页添加了演示动画,但播放速度太快。如何达到正常速度?下面的链接是一个有问题的动画。 问题动画链接:https://saybgm.github.io/Lottie_example/
您可以在 www.dynamicpoa.com 中查看正在发生的事情 只需滚动,您就会看到一切正常,除了标题上方的 SVG 动画 (Lottie)。在两个页面中(“/”和“/cursos”)。 任何人
我正在使用 Lottie 2.1.3、XCode 9 和 IOS 11。 当我试图获得这样的动画时 var loadingView = LOTAnimationView(name: "preloade
我正在开发适用于 iOS 和 Android 的应用程序。启动画面有一个 JSON 动画。在 iOS 中,动画完美运行,但在 Android 中,相同的动画运行有滞后。有人体验过吗? 注意事项:动画没
我有一个问题要问那些有使用 lottie json 文件经验的人。我使用 lottie 的经验不多,所以我想我可能缺少一些明显的知识。当我将动画渲染到 View 中时,动画对象会像那样放置在 View
我正在使用 Lottie 文件来制作动画。它没有按预期加载。应该是这样的http://www.lottiefiles.com/48-progress-bar 当前状态:https://www.drop
我的设计师给了我一个 Lottie (json) 文件,它包含文本。 其他图片显示正确,但文字显示不正确。它必须在中心但在右侧。 这是 GitHub issue .一种解决方案是将文本更改为形状并再次
我正在尝试使用 lottie 进行简单的加载。我找到了这个动画:https://lottiefiles.com/18563-cooking#_= _ 它存储在 SRC/Main/res/raw
我试图在某些帧之间循环动画,但我根本看不到动画,如果我删除 LottieCompositionFactory....addListener 代码并只使用 xml 文件,动画确实会显示,但我想在某些帧之
我想知道如何在 Lottie 动画中动态输入文本。一切都指向 TextDelegate。 我确实有一个动画,当我使用文本委托(delegate)时,文本的位置在 Y 轴上偏移 50-60 像素,在 X
我必须在 android 中使用 lottie 动画作为启动画面。我已经使用 match parent 作为宽度和高度。但它向我展示了屏幕边缘的一些填充,如附图所示。如果我使用 scaletype 作
使用 Lottie Android库,是否可以让用户与正在播放的动画元素进行交互? 比如,在动画中有一个按钮(不是原生按钮)并对点击它使用react? 最佳答案 json 文件被解释并将 SVG 输出
我正在使用 Glide 将图像加载到我的 Activity 中(在回收站 View 内),并且我想使用 Lottie 加载动画文件作为占位符。 所以这是我的 Glide 代码: Glide.with(
我正在创建一个底部导航,图标需要是一个动画 Lottie 文件。 似乎不可能为标签编写绑定(bind)适配器。是否有任何解决方案可以让我们在底部导航中拥有乐透动画? ** 最佳答案 首先创建一个自定义
通过赋予它自己的观点,我已经成功地将 Lottie 应用到我的程序中。虽然一旦被调用,动画只播放一次。我将如何使动画循环?谢谢你。 LottieView(与 Lottie 一起查看。) import
为了实现标题中所述的目标,我有两个单独的问题。 第一个问题是:com.airbnb.lottie.LottieAnimationView 的可见性状态是什么?默认情况下在 XML 中?我在我的 XML
我找到了 Lottie Play/Pause button ,但我不知道如何在我的音频播放器暂停时显示播放状态,在播放器播放时显示暂停状态并在其中重复播放均衡器动画(请参阅乐透预览)。我已阅读文档,但
我是一名优秀的程序员,十分优秀!