CoordinatorLayout在底部留下空后滚动 [英] CoordinatorLayout leaves empty space at the bottom after scrolling
问题描述
我想实现谷歌的最新设计技巧与CoordinatorLayout并与滚动和视差效应的问题。
I am trying to implement Google's newest design tricks with CoordinatorLayout and have problems with scrolling and parallax effect.
显示活动结束后,一切都看起来不错,但是当我尝试滚动出现问题。这似乎底部的观点是不正常扩大,它的滚动后,空如下。底视图似乎只拥有多少顶视图和导航栏之间的初始画面上大了。
After Activity is displayed, everything looks ok but the problem occurs when I try to scroll. It seems the bottom View is not expanded correctly and after it's scrolled up, empty space appears below. Bottom View seems to be big only how much it has on initial display between top View and nav bar.
这看起来是这样的:
相关code:
<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">
<CoordinatorLayout
android:layout_height="match_parent"
android:layout_width="match_parent">
<AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<CollapsingToolbarLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_scrollFlags="scroll|exitUntilCollapsed"
app:expandedTitleMarginStart="72dp"
app:expandedTitleMarginEnd="16dp">
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_collapseMode="parallax"/>
</CollapsingToolbarLayout>
</AppBarLayout>
<ViewPager
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"/>
</CoordinatorLayout>
</FrameLayout>
这怪异的行为发生随机。有时底部视图是滚动的正常和空不会出现。我究竟做错了什么?谢谢你。
This weird behavior happens randomly. Sometimes bottom View is scrollable normally and that empty space doesn't appear. What am I doing wrong? Thanks.
推荐答案
尝试添加工具栏
里面你的 CollapsingToolbarLayout
<android.support.design.widget.CollapsingToolbarLayout>
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:minHeight="?attr/actionBarSize"
app:layout_collapseMode="pin"/>
...
</android.support.design.widget.CollapsingToolbarLayout>
也尝试添加
安卓了minHeight =?ATTR / actionBarSize
android:minHeight="?attr/actionBarSize"
到工具栏
CollapsingToolbarLayout
和 AppBarLayout
这篇关于CoordinatorLayout在底部留下空后滚动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!