英文:
Flutter: Shift in Android launch theme and normal theme image
问题
在我的Flutter应用中,我为Android应用提供了LaunchTheme和NormalTheme,两者都使用相同的XML。但是,当应用程序打开时,首先显示启动屏幕,图像位于中心,但当加载正常主题时,图像会向下移动一点。我该如何解决这个问题?
英文:
In my flutter app, I provided LaunchTheme and NormalTheme for the android app
Both using the same xml
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@android:color/white" />
<item>
<bitmap
android:gravity="center"
android:src="@mipmap/launch_image" />
</item>
</layer-list>
But when the app opens, it shows the launch screen first with the image at center, but when it loads the normal theme, the image is shifted down a bit.
How can I resolve this?
答案1
得分: 2
我是Android的新手。
我遇到了相同的问题。
根据flutter启动屏幕的文档,NormalTheme看起来很合理,似乎可以很好地避免应用程序启动之前的白屏问题。但由于某种原因,它将主体部分下移了一点,看起来用户体验不佳。
文档中进一步介绍了如何添加启动屏幕。
您可以显示与启动主题相同的内容,甚至可以默认淡入您的根页面。
像这样在activity标签内添加启动屏幕标签
<activity android:name=".MainActivity"...>
.
.
.
<meta-data android:name="io.flutter.embedding.android.SplashScreenDrawable"
android:resource="@drawable/launch_background" />
</activity>
删除正常主题的meta标签,这是不必要的。
现在发帖可能已经太晚了,但还是分享一下。
英文:
I'm new to Android.
I've faced the same issue.
Based on the documentation for flutter splash screen NormalTheme makes sense and seems to work fine for avoiding the white screen before the app launches. But for some reason, it shifts the body tad bit lower which looks like bad UX.
further down in the documentation there's how to add a splash screen.
you could show the same thing as launch theme, even better you get a fade in of your root page by default.
add the splash screen tag inside the activity tag like this
<activity android:name=".MainActivity"...>
.
.
.
<meta-data android:name="io.flutter.embedding.android.SplashScreenDrawable"
android:resource="@drawable/launch_background" />
</activity>
Remove the normal theme meta tag, it won't be neccessary.
It's too late to post this, but here it is.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论