【发布时间】:2017-02-17 12:49:51
【问题描述】:
在下面的布局中,在 AppBarLayout 之后和 RecyclerView 之前,出现了一些额外的空白,我无法弄清楚它是如何出现的。
我已经检查了边距和所有内容,似乎没问题。
同样由于同样的原因,我相信 RecyclerView 的最后一个元素是从布局视图中裁剪出来的。
任何帮助表示赞赏。
<?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"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/transMain"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<android.support.design.widget.AppBarLayout
android:id="@+id/app_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="true"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/toolbar_layout"
android:layout_width="match_parent"
android:layout_height="80dp"
android:fitsSystemWindows="true"
android:paddingLeft="12dp"
app:contentScrim="?android:attr/colorPrimary"
app:layout_scrollFlags="exitUntilCollapsed">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbarAct"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/colorPrimary"
app:layout_scrollFlags="scroll">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<!--button was here-->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<RelativeLayout
android:id="@+id/monthSelLay"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:id="@+id/monthButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:textColor="#000"
android:textSize="14sp" />
<ImageView
android:layout_width="22dp"
android:layout_height="22dp"
android:layout_marginTop="12dp"
android:layout_toRightOf="@id/monthButton"
android:src="@drawable/ic_keyboard_arrow_down_black_24dp" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/syncLay"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:id="@+id/syncButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="50dp"
android:layout_marginTop="8dp"
android:text="SyncUp"
android:textAlignment="center"
android:textColor="#000" />
<ImageView
android:layout_width="22dp"
android:layout_height="22dp"
android:layout_marginTop="5dp"
android:layout_toRightOf="@+id/syncButton"
android:src="@drawable/ic_cached_black_48dp" />
</RelativeLayout>
</LinearLayout>
<!--switch was here-->
</RelativeLayout>
</android.support.v7.widget.Toolbar>
</android.support.design.widget.CollapsingToolbarLayout>
<android.support.v7.widget.SearchView
android:id="@+id/searchTrans"
android:layout_width="350dp"
android:layout_height="40dp"
android:layout_below="@+id/toolbar"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="10dp"
android:layout_marginTop="10dp"
android:background="#fff"
android:hint="Start typing an Amount/Description"
android:textColor="#000"
android:textColorHint="#ccc"
app:tabMode="scrollable" />
<!--need to change the background as an object oval prbbly-->
</android.support.design.widget.AppBarLayout>
<android.support.v7.widget.RecyclerView
android:id="@+id/trans"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center_horizontal"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
</android.support.v7.widget.RecyclerView>
</android.support.design.widget.CoordinatorLayout>
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_margin="@dimen/fab_margin"
android:src="@drawable/ic_add_black_24dp"
app:backgroundTint="@color/colorAccent"
app:elevation="6dp"
app:pressedTranslationZ="12dp" />
</FrameLayout>
在第一张图片中,我稍微向上滚动以显示空白。
【问题讨论】:
标签: android layout view android-recyclerview