android - CoordinatorLayout 在 AppBarLayout 和 RecyclerView 之间增加空间

标签 android android-design-library android-coordinatorlayout android-appbarlayout

CoordinatorLayoutAppBarLayoutRecyclerView 之间添加空间。不确定它是 Toolbar 还是 AppBarLayout

在手机上呈现的布局的屏幕截图:

Screenshot of the rendered layout on phone

Studio 上的设计效果图并没有这个空间。

知道发生了什么事吗?

代码本身。

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:app="http://schemas.android.com/apk/res-auto"
  xmlns:tools="http://schemas.android.com/tools"
  android:id="@+id/activity_home_framelayout"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:animateLayoutChanges="true"
  >

  <android.support.v4.widget.DrawerLayout
    android:id="@+id/drawer_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:animateLayoutChanges="true"
    >

    <android.support.design.widget.CoordinatorLayout
      xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:app="http://schemas.android.com/apk/res-auto"
      xmlns:tools="http://schemas.android.com/tools"
      android:id="@+id/activity_home_coordinator"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:fitsSystemWindows="true"
      tools:context=".ActivitySignIn">


      <android.support.design.widget.AppBarLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:theme="@style/AppTheme.AppBarOverlay"
        app:elevation="0dp"
        >

        <android.support.v7.widget.Toolbar
          android:id="@+id/toolbar"
          android:layout_width="match_parent"
          android:layout_height="?attr/actionBarSize"
          android:background="@color/colorPrimary"
          android:theme="@style/OTGToolbarTheme"
          >

          <TextView
            android:id="@+id/toolbar_title"
            style="@style/textTitle"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:text="You are logged in"
            android:textColor="@color/colorAccent"/>
        </android.support.v7.widget.Toolbar>

      </android.support.design.widget.AppBarLayout>

      <android.support.v7.widget.RecyclerView
        android:id="@+id/activity_home_articlecontainer"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        android:layout_marginTop="0dp"
        android:background="@color/colorPrimary"
        android:clipToPadding="false"
        android:paddingTop="0dp"
        app:behavior_overlapTop="?attr/actionBarSize"
        app:layout_behavior="@string/appbar_scrolling_view_behavior"
        />
    </android.support.design.widget.CoordinatorLayout>

    <android.support.v7.widget.RecyclerView
      android:id="@+id/NavigationDrawer"
      android:layout_width="wrap_content"
      android:layout_height="match_parent"
      android:layout_gravity="start"
      android:background="@color/colorPrimary"
      android:scrollbars="vertical"
      />
  </android.support.v4.widget.DrawerLayout>

  <FrameLayout
    android:id="@+id/activity_home_overlay"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:clickable="true"
    android:visibility="gone">

    <LinearLayout
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:background="@color/tlgray0"
      android:orientation="vertical"/>

    <ProgressBar
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_gravity="center"
      android:indeterminate="true"/>
  </FrameLayout>
</FrameLayout>

最佳答案

从您的第一个 Recycler View 中删除以下行,其 ID 为 activity_home_articlecontainer

 android:layout_gravity="start"

关于android - CoordinatorLayout 在 AppBarLayout 和 RecyclerView 之间增加空间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37209342/

相关文章:

android - 更改 float 标签 EditText 和 TextInputLayout 的字体

android - 如何折叠 AppBarLayout 的内容而不是工具栏

android - 未调用具有自定义行为的 CoordinatorLayout

android - 选项卡布局仅在滑动时折叠,而不是在慢速滚动时折叠

android - LiveData Room 进入后台时丢失数据

android - 在紧凑 View 中显示按钮的 MediaStyle 通知

android - 是否有 Android Material Design 的默认高度集合?

android - 滚动 AppBarLayout 内部的 RecyclerView 在滚动外部 RecycleView 时禁用滚动滞后

Android Studio - 如何在 webview Lollipop 中上传文件 (Android 5.0)

Android 数据库版本控制