小编Pri*_*sal的帖子

突然在CoordinatorLayout Android内的ViewPager Fragment中使用NestedScrollView滚动

ViewPager内心面临一个重大的滚动问题CoordinatorLayout.

当前场景:

  1. app:appbarScrollingViewBehaviour已开启ViewPager.
  2. ViewPager片段具有NestedScrollView其根父母.
  3. 片段布局包含Horizo​​ntal RecyclerView.
  4. 当我通过触摸向上滚动时RecyclerView,应用栏不会滚动,而是仅进行嵌套滚动.
  5. 当我通过触摸视图的其余部分滚动时,CoordinatorLayout滚动.6)嵌套滚动也在中途停止并切断内容.

我已经尝试过了:

  1. ViewPager里面NestedScrollView并设置 app:appbarScrollingViewBehaviour属性NestedScrollView.这完全切断了碎片内容,因为RecyclerView无法确定其高度.
  2. 设置setAutoMeasureEnabled(true)RecyclerView,依然没能解决的高度.
  3. 还有很多其他方法.

    请帮助解决这个问题.在上传的.gif文件中可以看到当前行为.我还发布了活动布局和片段布局以及RecyclerView行布局的代码.

谢谢

activity.xml:

<android.support.design.widget.CoordinatorLayout  
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:Customs="http://schemas.android.com/apk/res-auto"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/new_color_primary_skim">

<android.support.design.widget.AppBarLayout
    android:id="@+id/appbar"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@color/transparent">

    <android.support.design.widget.CollapsingToolbarLayout
        android:id="@+id/collapsingLayout"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fitsSystemWindows="true"
        android:elevation="0dp"
        app:layout_scrollFlags="scroll|exitUntilCollapsed"
        android:minHeight="?attr/actionBarSize">


        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:fitsSystemWindows="true"
            app:layout_scrollFlags="scroll|enterAlways"
            android:layout_height="?attr/actionBarSize">

            <FrameLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent">

                <ImageView …
Run Code Online (Sandbox Code Playgroud)

android android-fragments android-recyclerview android-coordinatorlayout

11
推荐指数
1
解决办法
3485
查看次数

如何自定义回收站视图的Grid Layout Manager?

我已经成功实现了一个循环计数为2的网格布局方式的回收站视图.现在我想实现如下图所示的内容.为此,我需要自定义我的网格布局管理器,使得1个元素的跨度计数为1,而对于休息,所有它都是2.无论如何都可以.

在此输入图像描述

android android-recyclerview

3
推荐指数
1
解决办法
5478
查看次数