To_Drill 2017-11-05 06:42 采纳率: 0%
浏览 3107
已结题

Android Fragment布局中的FitsSystemWindows=true无效!

我用的是ViewPage+Fragment想要做到把UI内容显示在Status bar上,
发现把状态栏透明后Toolbar就和状态栏重叠了,
然后我就加了FitsSystemWindows=true这行代码但是没有任何效果,
我试过加载Activity的布局中效果是有的,布局会自动空出一个Status bar
大小的PaddingTop但在Fragment布局中就是没有效果,
不管是加在根布局还是子布局中都无效。我只有自己在Toolbar中写上一个
PaddingTop才能让它们不重叠,不过这是偏方。。。。
布局代码:
<?xml version="1.0" encoding="utf-8"?>
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
>

<android.support.v7.widget.RecyclerView
    android:id="@+id/home_item"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#f1f5f6"/>

<android.support.v7.widget.Toolbar
    android:id="@+id/home_toolbar"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:elevation="4dp"
    android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
    app:popupTheme="@style/ThemeOverlay.AppCompat.Light">

<android.support.v7.widget.SearchView
    android:id="@+id/home_searchView"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginLeft="18dp"
    app:defaultQueryHint="请输入菜品或用户"
    app:iconifiedByDefault="false"/>

</android.support.v7.widget.Toolbar>

  • 写回答

5条回答

  • 有理叔 2017-11-06 03:57
    关注

    试试将Activity的样式改为无NoActionBar

    评论

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器