【问题标题】:Android draw under status barAndroid在状态栏下绘制
【发布时间】:2015-06-20 15:51:23
【问题描述】:

我正在设计一个在 Android Lollipop 上的应用程序,该应用程序在状态栏下绘制一个Navigation Drawer。我在这方面取得了部分成功。我可以让抽屉在状态栏下绘制,但不能让抽屉的内容。





我的抽屉里没有任何填充物,TextView 上也没有边距。这是我的 layout.xml 文件:

<android.support.v4.widget.DrawerLayout
  android:id="@+id/drawer_layout"
  xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:tools="http://schemas.android.com/tools"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  tools:context=".HomeActivity"
  android:fitsSystemWindows="true">

   <!--window content -->
  <LinearLayout
    android:id="@+id/content_frame"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:fitsSystemWindows="true">

    <Toolbar
      android:id="@+id/toolbar"
      android:layout_width="match_parent"
      android:layout_height="56dp"
      android:background="#FF5722"
      android:theme="@android:style/ThemeOverlay.Material.Dark.ActionBar"
      android:minHeight="?android:attr/actionBarSize"
      android:elevation="4dp"/>

    <android.support.v7.widget.RecyclerView
      android:id="@+id/grid_recycler_view"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:scrollbars="vertical"/>

  </LinearLayout>

  <!-- The navigation drawer -->
  <RelativeLayout
    android:id="@+id/left_drawer"
    android:layout_width="320dp"
    android:layout_height="match_parent"
    android:layout_gravity="start"
    android:background="#f5f5f5"
    android:elevation="16dp"
    android:fitsSystemWindows="true">

    <TextView
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:text="Hello, Drawer!"
      android:fitsSystemWindows="true"/>

  </RelativeLayout>

</android.support.v4.widget.DrawerLayout>


我已经尝试在TextView 上放置一个负顶部填充,但它只是被夹在状态栏下方,我只看到抽屉背景。如何让抽屉元素的子元素在状态栏下绘制?

谢谢

【问题讨论】:

    标签: android android-layout drawerlayout


    【解决方案1】:

    事实证明,我认为 android:fitsSystemWindows="true" 的做法与实际情况相反,所以只需从所有视图中删除它,它应该可以完美运行。感谢 Google Plus 上的+der Android Pro

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-05-12
      • 1970-01-01
      相关资源
      最近更新 更多