【发布时间】:2015-10-16 10:33:35
【问题描述】:
我在 Activity 中使用折叠工具栏。我想在其中显示一个列表,为此我使用 RecyclerView。这工作正常。但现在我想在 Recyclerview 下方显示一个按钮。正如我red some where 我们只能在 collpasing-toolbar 布局中放置一个可滚动元素。我已经有一个 Recyclerview 我怎么能在它下面放一个按钮?我知道如果我使用 nestedScrollview 可以放置多个视图,但它不适用于 Recyclerview。
我尝试了什么
我尝试使用nested-scrollview 来显示recyclerview 和按钮,但是recyclerview 在嵌套scrollview 中不起作用。以下是我的布局xml 代码。
<android.support.design.widget.AppBarLayout
android:id="@+id/app_bar_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="true"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/collapsing_toolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
app:contentScrim="?attr/colorPrimary"
app:expandedTitleMarginEnd="64dp"
app:expandedTitleMarginStart="48dp"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="true">
<com.andy.app.util.ui.SquareImageView
android:id="@+id/Icon"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scaleType="centerCrop"
app:layout_collapseMode="parallax"
app:layout_collapseParallaxMultiplier="0.7" />
<View
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/groupIcon"
android:background="@drawable/coll_toolbar_image_gradient" />
</RelativeLayout>
<android.support.v7.widget.Toolbar
android:id="@+id/anim_toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_collapseMode="pin"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v7.widget.RecyclerView
android:id="@+id/List"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/transparent_white"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
<Button
android:layout_width="fill_parent"
android:layout_height="60dp" />
</android.support.design.widget.CoordinatorLayout>
【问题讨论】:
标签: android android-layout android-5.0-lollipop material-design android-collapsingtoolbarlayout