[英]Splash Screen not full screen in android device flutter. Tried everyting. Using flutter_native_splash
Pubspec.YAML 代码-
flutter_native_splash: ^2.0.1+1
flutter_native_splash:
image: assets/images/splashScreen.png
color: "#c988be"
Styles.xml -
style name="LaunchTheme" parent="@android:style/Theme.Light.NoTitleBar">
<!-- Show a splash screen on the activity. Automatically removed when
Flutter draws its first frame -->
<item name="android:windowBackground">@drawable/launch_background</item>
<item name="android:windowFullscreen">true</item>
</style>
如果要隐藏操作栏,则需要转到应用程序清单,然后将启动屏幕布局的主题设置为无操作栏,如下所示:
android:theme="@style/Theme.AppCompat.NoActionBar"
如果您还想隐藏状态栏,您可以在初始屏幕活动中使用标志,如下所示:
@Suppress("DEPRECATION")
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
window.insetsController?.hide(WindowInsets.Type.statusBars())
}else{
window.setFlags(
WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN
)
}
你必须检查这个包flutter_native_splash ,在这个包中你只需要设置你的启动画面图像路径。
将此代码添加到您的 pubspec.yaml 文件中
flutter_native_splash:
background_image: "assets/images/splash_bg.png"
确保运行此命令:
flutter pub run flutter_native_splash:create
不幸的是,Android 没有很好的支持在不扭曲图像的情况下填充屏幕。 解决此问题的一种方法是使启动画面大于所需的大小,然后启动画面将被屏幕大小裁剪。
你好越南同胞Trung Đoan,就我而言,只要留下“image: assets/splash.png”就可以了,添加
<item>
<bitmap android:gravity="center" android:src="@drawable/splash"/>
</item>
在launch_background.xml文件中,按照你说的做rest,谢谢<3
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.