android - 在 Android 的 Surface View 游戏循环中实现 Lottie 动画
问题描述
好的,所以我现在面临的主要问题是,我们知道将子视图添加到表面视图中,我们只能绘制,所以我实现了一个扩展表面视图的自定义视图,现在为了向其中添加子视图,我已经从xml 使用布局充气器和表面视图的 onDraw 方法我已经绘制了它,但问题是 Lottie 动画无法正确显示。
自定义视图
public class CustomView extends SurfaceView implements SurfaceHolder.Callback, Runnable {
@Override
public void run() {
//Draw onto canvas
}
}
动画视图.xml
<?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"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="@dimen/dimen_150"
android:layout_height="@dimen/dimen_150">
<com.airbnb.lottie.LottieAnimationView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="visible"
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_loop="false"
app:lottie_rawRes="@raw/score_counter_green"/>
<TextView
android:id="@+id/HeadingTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
android:fontFamily="@font/monospec_medium"
android:text="@string/heading_score"
android:textColor="@color/colorWhite"
android:textSize="@dimen/text_size_15"
android:textStyle="bold|italic"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
解决方案
推荐阅读
- mysql - 当特定数据发生变化时,从 MySQL 向 Jenkins 发出警报
- php - 如何在php mailer中设置发件人名称?
- gyroscope - 传感器输出“大约 65535”而不是“大约零”
- git - Git 将当前分支(非主分支)推送到新的仓库
- javascript - 如何为动态生成的按钮编写 onclick 函数
- xml - 使用 XSLT 基于条件将 XML 节点属性动态传递给其他节点
- linux - 将 dd 映像写入 NFS (AWS EFS)
- ruby-on-rails - 循环中的值总和并保持最高值
- javascript - 变量似乎未定义和同时定义?
- jenkins - Bitbucket PR builder Job 没有被触发