java - 带有自定义视图的 Flutter SplashScreen 实现
问题描述
我阅读了 Flutter 关于几个 Splash screen implementation 的文章(文章链接),我选择将它与 View 一起使用,但我不知道如何激活它。任何人都可以帮助我吗?不管怎么说,还是要谢谢你。
splash_screen_view_template
<FrameLayout 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="match_parent"
android:layout_height="match_parent">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/splash_text"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
splash_screen_view_class
public class SplashScreenView extends View {
...
}
splash_screen_interface
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.bonfry.splash_screen.SplashScreenView;
import io.flutter.embedding.android.SplashScreen;
public class SplashScreenWithTransition implements SplashScreen {
private SplashScreenView mySplashView;
@Override
@Nullable
public View createSplashView(
@NonNull Context context,
@Nullable Bundle savedInstanceState
) {
mySplashView = new SplashScreenView(context);
return mySplashView;
}
@Override
public void transitionToFlutter(@NonNull Runnable onTransitionComplete) {
onTransitionComplete.run();
}
}
解决方案
推荐阅读
- python - 在python中解析内存xml
- python - Python 中的快捷方式,用于将自身内部的类名作为别名引用
- c# - Xamarin Android 中的 Mvvm 导航问题
- javascript - 如何将javascript数组转换为python字典
- python-3.x - 插入到最大二进制堆和 ValueError
- ios - adjustsFontSizeToFitWidth 应该做什么?
- java - 递归删除数组中所有相邻的重复数字
- powershell - 如何使用 powershell 计算文件中的连续字符串?
- java - 从同一控制器的另一个 REST 端点直接调用 REST 端点(方法)是一种好习惯吗?
- c# - 为什么我不能使用 EF6 和 SQlite 查询 DATETIME 字段?