相关疑难解决方法(0)

Android布局:具有滚动行为的Viewpager内的垂直Recyclerview内的水平Recyclerview

这是我正在尝试使用以下所有元素构建的应用程序:

蔬菜应用程序

但是,一切正常,我希望内部水平回收视图不捕获任何垂直滚动.所有垂直滚动必须朝向外部垂直回收视图,而不是水平回滚视图,因此垂直滚动将允许工具栏根据其scrollFlag退出视图.

当我将手指放在recyclerview的"StrawBerry Plant"部分并向上滚动时,它会滚出工具栏:

草莓植物

如果我将手指放在水平滚动视图上并向上滚动,它根本不会滚出工具栏.

以下是我目前为止的xml布局代码.

活动的XML布局:

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
    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:id="@+id/fragment_container"
    android:clipChildren="false">

    <android.support.design.widget.CoordinatorLayout
        android:orientation="vertical"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:id="@+id/container"
        >

    <android.support.design.widget.AppBarLayout
        android:id="@+id/appBarLayout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

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

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

        <android.support.design.widget.TabLayout
            android:id="@+id/sliding_tabs"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="?attr/colorPrimary"
            style="@style/CustomTabLayout"
            />

    </android.support.design.widget.AppBarLayout>
    <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>

</FrameLayout>
Run Code Online (Sandbox Code Playgroud)

"水果"片段 XML布局(其是用于该片段编码-片段被标记在上面图片):

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <ProgressBar
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/progressBar"
        android:visibility="gone"
        android:layout_centerInParent="true"
        android:indeterminate="true"/>

<!--    <android.support.v7.widget.RecyclerView-->
    <com.example.simon.customshapes.VerticallyScrollRecyclerView
        android:id="@+id/main_recyclerview"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        />

</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)

我使用了一个名为VerticallyScrollRecyclerView的自定义类,该类跟随google在视图组中处理触摸事件的示例.它的目的是拦截和使用所有垂直滚动事件,以便它可以滚动/滚出工具栏: …

android android-layout android-recyclerview android-coordinatorlayout android-appbarlayout

59
推荐指数
3
解决办法
3万
查看次数

嵌套的RecyclerView滚动问题

在我的应用程序中,我有垂直父级,RecyclerView其中包含很少的水平子级ViewHolders.但我有非常烦人的滚动问题 - 在我垂直滚动父RV之后我想滚动我的一个孩子RV但父母只是拦截所有的动作事件,直到我从屏幕上移开我的手指然后把它放回去.这是令人讨厌的行为的例子.

https://i.imgur.com/dPtmAXD.gif

我尝试了这个问题的每个解决方案 - 嵌套的RecyclerView.如何在子级RecyclerView滚动时阻止父级RecyclerView滚动?

什么都不适合我.

看起来Google Play Market具有相同的RV层次结构,但是滚动非常好.我试图从其他主题实现一些解决方案,但没有任何工作按预期.

我不知道我应该发布什么代码,但这里是我的父RV的ViewHolder示例与嵌套RV.

private class UserEventsViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
        private RecyclerView rvUserEvents;
        private HomeUserEventsRVAdapter rvAdapter;

        public UserEventsViewHolder(View v) {
            super(v);

            rvUserEvents = v.findViewById(R.id.rv_user_events);
            rvUserEvents.setLayoutManager(new LinearLayoutManager(itemView.getContext(), LinearLayoutManager.HORIZONTAL, false));
            rvUserEvents.setNestedScrollingEnabled(false);
            rvUserEvents.setRecycledViewPool(viewPool);
            rvAdapter = new HomeUserEventsRVAdapter(presenter);
            rvUserEvents.setAdapter(rvAdapter);

            v.findViewById(R.id.btn_all_user_events).setOnClickListener(this);
        }

        private void bind(UserItemViewModel userItem) {
            rvAdapter.updateAdapter(userItem);
        }

        @Override
        public void onClick(View v) {
            switch (v.getId()) {
                case R.id.btn_all_user_events:
                    presenter.openUserEventsList();
                    break;
            }
        }
    }
Run Code Online (Sandbox Code Playgroud)

编辑:我的活动的XML代码

<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/cl_root"
android:layout_width="match_parent" …
Run Code Online (Sandbox Code Playgroud)

android scroll android-recyclerview nestedrecyclerview

13
推荐指数
1
解决办法
2084
查看次数