【问题标题】:method setFitsSystemWindows(true) does nothing方法 setFitsSystemWindows(true) 什么都不做
【发布时间】:2016-04-21 18:09:32
【问题描述】:

我的项目包含一个 MainActivity 和 6 个片段。我想将布局设置为适合 1 个特定片段而不是其他片段的系统窗口。所以我所做的是我把这段代码 getActivity().findViewById(R.id.coordinatorLayout).setFitsSystemWindows(true); 在那个片段的 onResume 方法中,并且 getActivity().findViewById(R.id.coordinatorLayout).setFitsSystemWindows(false); 在其他人的 onResume 方法中。

结果证明setFitsSystemWindows(false) 方法有效,但是 setFitsSystemWindows(true) 什么都不做

在调用setFitsSystemWindows(true) 之后,应用程序视图仍然设置为不适合系统 Windows,所以我想知道我是否做错了什么或者该方法无法正常工作。

提前谢谢你。任何答案将不胜感激。

更新:我在调用 .getFitsSystemWindows() 之后调用 .getFitsSystemWindows() 并且它返回 true - 不执行任务。

【问题讨论】:

标签: java android android-fragments


【解决方案1】:

如果你想在状态栏下显示一些东西,试试这个

getWindow().getDecorView().setSystemUiVisibility(
    View.SYSTEM_UI_FLAG_LAYOUT_STABLE
    | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
getWindow().setStatusBarColor(Color.TRANSPARENT);

Here 是更详细的解决方案。

【讨论】:

    猜你喜欢
    • 2014-01-21
    • 2021-12-04
    • 2010-11-13
    • 1970-01-01
    • 1970-01-01
    • 2013-05-07
    • 2015-01-13
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多