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 安卓adb backup备份应用数据失败
  • ¥15 eclipse运行项目时遇到的问题
  • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
  • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
  • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站
  • ¥50 成都蓉城足球俱乐部小程序抢票
  • ¥15 yolov7训练自己的数据集
  • ¥15 esp8266与51单片机连接问题(标签-单片机|关键词-串口)(相关搜索:51单片机|单片机|测试代码)
  • ¥15 电力市场出清matlab yalmip kkt 双层优化问题
  • ¥30 ros小车路径规划实现不了,如何解决?(操作系统-ubuntu)