【发布时间】:2024-04-29 02:25:01
【问题描述】:
尝试在 Flutter android 中实现自定义闪屏视图。 Launchbackground.xml 不符合我的要求。我有 2 张图片,一张是背景图片,另一张是顶部图片。
尝试这个 url 自定义闪屏会话 Creating a custom SplashScreen
分享示例代码
class SplashScreen : SplashScreen {
override fun createSplashView(context: Context, savedInstanceState: Bundle?): View? {
TODO("Not yet implemented")
//return SplashActivity();
return LayoutInflater.from(context).inflate(R.layout.activity_splash, null, false);
}
override fun transitionToFlutter(onTransitionComplete: Runnable) {
TODO("Not yet implemented")
//mySplashView.animateAway(onTransitionComplete);
onTransitionComplete.run();
}
}
<RelativeLayout 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="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/spalshscreenbg"
android:fitsSystemWindows="false"
>
<ImageView
android:id="@+id/logo_id"
android:layout_marginTop="30dp"
android:layout_width="fill_parent"
android:layout_height="300dp"
android:src="@drawable/topimage"/>
【问题讨论】:
-
黑屏先显示后只显示闪屏。这是因为 manifest.xml 文件中的主题设置 android:theme="@style/LaunchTheme"
标签: android flutter splash-screen