Android 在状态栏下绘制

标签 android android-layout drawerlayout

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


Screenshot of device with drawer layout


抽屉上没有任何填充,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:fitsSystemWindows="true" 做了与实际相反的事情,所以只需从所有 View 中删除它,它应该可以完美运行。感谢+der Android Pro在 Google Plus 上。

关于Android 在状态栏下绘制,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30955945/

相关文章:

java - 在RelativeLayout上检测多点触摸

android - 通过代码获取Android用户定义的设备名称

android - 向 View 添加自定义属性

android - 当 DrawerLayout 可见时不要调暗主要内容?

java - 将 DrawerLayout 与 ListView 一起使用

android - 如何将 DrawerLayout 与 ConstraintLayout 一起使用

Android弹出菜单位置

java - Android Studio Soundboard 按钮在切换 Activity 后不会播放声音我只能按 7 次才停止

Android:在翻译中缩放 EditText Android 问题并在放置在 parentView 外部时获取 childView 的 Touch 事件

android - 输入类型无法正常工作