【发布时间】:2016-09-11 18:39:31
【问题描述】:
我正在尝试制作类似于发布的图像的内容,但假设 viewpager 可以使用 recyclerView 滚动,标题是简单的线性/相对布局,这将是静态的,fab 相同(不可滚动)但不工作。
我在下面发布了我的布局
<android.support.design.widget.CoordinatorLayout
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:fitsSystemWindows="true">
<include layout="@layout/layout_view_pager"
app:layout_collapseMode="parallax"
app:layout_behavior="@string/appbar_scrolling_view_behavior"/>
<android.support.v7.widget.RecyclerView
android:id="@+id/list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="true"
android:saveEnabled="false"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
<android.support.design.widget.AppBarLayout
android:id="@+id/appbar"
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="wrap_content"
android:fitsSystemWindows="true"
app:contentScrim="?attr/colorPrimary"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<RelativeLayout
android:id="@+id/header_labels"
android:layout_width="match_parent"
android:layout_height="@dimen/header_height"
android:background="@color/brand_green"
app:layout_collapseMode="pin"
android:orientation="vertical">
<TextView
android:id="@+id/actionbar_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:textColor="@android:color/white"
android:textSize="43sp"/>
<TextView
android:id="@+id/actionbar_balance_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_marginTop="5dp" android:textSize="13sp"/>
</RelativeLayout>
<android.support.v7.widget.Toolbar
android:id="@+id/my_toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_collapseMode="pin"
app:contentInsetStart="0dp">
<TextView
android:id="@+id/chime_sign"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
app:iconFontColor="@android:color/white"
app:iconFontSize="26sp"/>
</android.support.v7.widget.Toolbar>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:clickable="true"
android:src="@drawable/fab_icon_mm"
app:elevation="6dp"
app:fabSize="normal"
app:rippleColor="@color/brand_dark_green"
app:pressedTranslationZ="12dp"
app:layout_anchor="@id/header_labels"
app:layout_anchorGravity="bottom|right|end"/>
【问题讨论】:
-
请解释一下“viewpager 可以使用 recyclerView 滚动”是什么意思
-
是的,当您开始滚动 recyclerView 时,viewpager 也会随着 collapsingtoolbarlayout(如果可能的话)滚动,类似于列表视图的标题
标签: android android-design-library android-collapsingtoolbarlayout android-appbarlayout