解决Flutter旋转屏幕状态栏空缺的问题

问题

最近要实现一个视频播放器,全屏播放时需要旋转屏幕,把案例拿出来试了一下,旋转屏幕后呈现的状态是这样
左侧由于打孔屏的缘故呈现黑色空缺。

解决办法

打开项目下android/app/src/main/res/values/styles.xml

添加<item name="android:windowLayoutInDisplayCutoutMode">shortEdges</item>

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <style name="LaunchTheme" parent="@android:style/Theme.Light.NoTitleBar">
        <item name="android:windowBackground">@drawable/launch_background</item>
    </style>
    <style name="NormalTheme" parent="@android:style/Theme.Light.NoTitleBar">
        <item name="android:windowBackground">?android:colorBackground</item>
        <item name="android:windowLayoutInDisplayCutoutMode">shortEdges</item>
    </style>
</resources>```

LaunchTheme下为启动页配置,NormalTheme下为普通页面配置

解决后

状态栏的空缺消失
在这里插入图片描述

总结

用flutter之前没有做过原生项目,很多配置都不清楚,OK!

猜你喜欢

转载自blog.csdn.net/weixin_44354735/article/details/126656201