【问题标题】:how to avoid the system bar in android ,flutter?如何避免android中的系统栏,颤振?
【发布时间】:2020-04-24 04:02:43
【问题描述】:

我正在尝试添加底部应用栏但出现问题,android 系统应用栏一直隐藏我的应用栏。我想要实现的是我的底部应用栏将底部扩展为与底部系统栏相同的高度

 bottomNavigationBar: SafeArea(
        child: BottomAppBar(
          color: Color(0xFFDFFFE6),
          child: BottomNavigationBar(items: <BottomNavigationBarItem>[
          BottomNavigationBarItem(
            title: Text("Trạng thái"),
            icon: Icon(
            Icons.assignment_turned_in,
            color: primary,
          ),),
            BottomNavigationBarItem(
              title : Text("Đổi quà"),
              icon: Icon(
              Icons.redeem,
              color: primary,
            ),)
        ],
        ),),
      ),

我的android的样式文件

<?xml version="1.0" encoding="utf-8"?>
<resources>

    <style name="LaunchTheme" parent="@android:style/Theme.Black.NoTitleBar">

    </style>

    <style name="NormalTheme" parent="@android:style/Theme.Black.NoTitleBar">
        <item name="android:windowBackground">@android:color/white</item><!-- Normal Background-->
        <item name="android:windowTranslucentNavigation">true</item>
        <item name="android:statusBarColor">@android:color/transparent</item>
        <item name="android:navigationBarColor">@android:color/transparent</item>
    </style>

</resources>

【问题讨论】:

    标签: flutter react-navigation-bottom-tab


    【解决方案1】:

    SystemChrome.setEnabledSystemUIOverlays([]) 应该做你想做的事。

    SystemChrome.setEnabledSystemUIOverlays(SystemUiOverlay.values) 再次显示。

    别忘了导入它。

    import 'package:flutter/services.dart';

    【讨论】:

    • 我应该把这段代码放在哪里?在 initstate 方法或方法 build 的开头
    • 如果我使用此代码的问题是我的顶部应用栏不再最大缩放
    • 我倾向于把它放在我班的initState(){ /* ... */} 中。尝试添加sized: false 来修复高度:github.com/flutter/flutter/issues/24472#issuecomment-440015464
    猜你喜欢
    • 1970-01-01
    • 2020-08-09
    • 1970-01-01
    • 1970-01-01
    • 2020-10-18
    • 2021-03-05
    • 1970-01-01
    • 2019-10-23
    • 2010-12-25
    相关资源
    最近更新 更多