【问题标题】:Parallax Collapse Toolbar wrong scroll and layout视差折叠工具栏错误的滚动和布局
【发布时间】:2017-07-06 16:27:29
【问题描述】:

我有以下布局:

    <?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    tools:context="br.com.myproject.view.fragment.ProductActivityFragment"
    android:id="@+id/main_content"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true">

    <android.support.design.widget.AppBarLayout
        android:id="@+id/app_bar_layout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
        android:fitsSystemWindows="true">

        <android.support.design.widget.CollapsingToolbarLayout
            android:id="@+id/collapsing_toolbar"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            tools:layout_scrollFlags="scroll|exitUntilCollapsed"
            tools:contentScrim="?attr/colorPrimary"
            tools:expandedTitleMarginStart="48dp"
            tools:expandedTitleMarginEnd="64dp"
            android:fitsSystemWindows="true">

            <ImageView
                android:id="@+id/ivImgProduct"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:scaleType="centerCrop"
                android:fitsSystemWindows="true"
                tools:layout_collapseMode="parallax"/>

            <android.support.v7.widget.Toolbar
                android:id="@+id/toolbar"
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                tools:layout_scrollFlags="scroll|enterAlways"
                tools:popupTheme="@style/ThemeOverlay.AppCompat.Light"
                tools:layout_collapseMode="pin">
            </android.support.v7.widget.Toolbar>

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

    <android.support.v7.widget.RecyclerView
            android:id="@+id/rvProductActions"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            tools:layout_behavior="android.support.design.widget.AppBarLayout$ScrollingViewBehavior">

        </android.support.v7.widget.RecyclerView>

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

工具栏上的 RecyclerView 保持“重叠”的外观。滚动 RecyclerView 作为 CollapsingToolbarLayout 不起作用。 我试图让我的布局保持example link 的行为,但使用 RecyclerView。

【问题讨论】:

  • 尝试为 AppBarLayout 设置一个高度,比如 170dp。
  • 我改变了大小,但这只会增加 AppBarLayout 的大小。我的 recyclerview 在 AppBarLayout 和他们的孩子下面。并且不回答的卷轴都被“冻结”了。
  • 显然这个命令不起作用工具:layout_behavior="@string/appbar_scrolling_view_behavior"

标签: android android-recyclerview android-collapsingtoolbarlayout


【解决方案1】:

经过多次尝试后,我使用了一个名为 Android-ObservableScrollView 的库,它成功了。它使用起来更简单,提供了几个示例,并且单个组件已经具有预期的效果。滚动内容必须大于空白屏幕空间才能使滚动生效,因为它没有iOS的反弹效果。

【讨论】:

    【解决方案2】:

    您必须将 app:layout_behavior="@string/appbar_scrolling_view_behavior" 添加到您的回收站视图中

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-09-03
      • 1970-01-01
      • 1970-01-01
      • 2015-08-14
      • 2015-11-23
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多