【问题标题】:Recyclerview + viewpager, make toolbar collapseRecyclerview + viewpager,使工具栏折叠
【发布时间】:2016-03-09 20:09:16
【问题描述】:

我在 viewpager 中有一个 recyclerview。我还有上面的选项卡和一个工具栏。当我向下移动 recyclerView 时,我想折叠那些(或我必须尝试的其中一个)。与here基本相同。 我无法让它工作。

这是我所拥有的:

<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:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    tools:context="com.cedric.testdesign.MainActivity">


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


        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:background="?attr/colorPrimary"
            app:popupTheme="@style/AppTheme.PopupOverlay" />

        <android.support.design.widget.TabLayout
            android:id="@+id/tabs"
            style="@style/MyCustomTabLayout"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"/>

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


    <com.signpetitions.cedric.signpetitions.components.MyFab
        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="@android:drawable/ic_dialog_email" />

    <android.support.v4.view.ViewPager
            android:id="@+id/viewpager"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            app:layout_behavior="@string/appbar_scrolling_view_behavior"/>


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

在 viewPager 我有一个带有回收器视图的片段:

<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.RecyclerView
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/recyclerView"
    app:layout_behavior="@string/appbar_scrolling_view_behavior" />

【问题讨论】:

标签: android android-layout material-design android-coordinatorlayout


【解决方案1】:

我将它添加到工具栏:

app:layout_scrollFlags="scroll|enterAlways"

然后就可以了。但问题是,当状态栏是透明的时,工具栏后面的文本是可见的。所以状态栏必须有颜色。

【讨论】:

    猜你喜欢
    • 2016-06-16
    • 2023-03-15
    • 1970-01-01
    • 1970-01-01
    • 2016-05-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多