【问题标题】:Trying to make Status bar and Navigation bar translucent, not transparent试图使状态栏和导航栏半透明,不透明
【发布时间】:2020-06-26 09:34:14
【问题描述】:

我正在尝试为学校项目制作我的第一个应用程序。通过关注其他人的问题和答案,我有时会获得半透明的状态栏,但导航只是变灰但没有来自活动的内容但是导航抽屉在状态和导航栏下方绘制,我怎样才能使活动在状态下方绘制还有导航栏?

enter image description here

enter image description here

图像 2 的代码在 onCreate 下:

getWindow().addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN);
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION,

WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);

我尝试使用 android:fitsSystemWindows="true" 并没有,已经有点难以理解了。

【问题讨论】:

  • 您是否尝试删除 android:fitsSystemWindows 和 FLAG_LAYOUT_NO_LIMITS?
  • 是的,我在状态栏中得到原色深色,在导航栏中得到黑色,它们后面什么都没有。 i.imgur.com/X2r2vV8.jpg

标签: java android android-studio


【解决方案1】:

在styles.xml中加入这两行就基本解决了

<item name="android:windowTranslucentNavigation">true</item>
<item name="android:windowTranslucentStatus">true</item>

因为我没有合适的工具栏而不是最优雅的?我认为。我需要将android:layout_marginTop="24dp" 放入activity_main.xml 以及几乎所有其他我可能在应用顶部有按钮的地方。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-07-16
    • 2017-08-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-05-28
    相关资源
    最近更新 更多