我可以像这样创建一个nestedScroll布局吗?

tin*_*ght 8 android scrollview android-recyclerview nestedscrollview

在此输入图像描述

我认为它可以通过实现NestedScrollingChild NestedScrollingParent.

但我无法理解他们.谁可以帮助我!

产品经理坚持设计.

ScrollView包含LinearLayout的"TabLayout"和ViewPager.

ViewPager包含2个fragment包含RecyclerView或仅仅只有2 RecyclerView.

ScrollView滚动到底部时,RecyclerView可以滚动到底.

RecyclerView滚动到顶部时,ScrollView可以滚动到顶部.

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="match_parent"
    android:layout_height="match_parent">
    <LinearLayout
        android:orientation="vertical"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />
        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />
        <TextView
            android:layout_width="match_parent"
            android:layout_height="1000dp" />
        <TableLayout
            android:layout_width="match_parent"
            android:layout_height="60dp"></TableLayout>
        <android.support.v4.view.ViewPager
            android:layout_width="match_parent"
            android:layout_height="match_parent"></android.support.v4.view.ViewPager>
    </LinearLayout>
</ScrollView>
Run Code Online (Sandbox Code Playgroud)

arb*_*rcr 6

只需将ScrollView更改 为android.support.v4.widget.NestedScrollView即可

如果不起作用,请发布您的xml


小智 2

\xd9\x90你可以这样做,但是使用这种类型的布局根本不好

\n\n

首先,您需要添加 ViewPager 和 RecyclerView 的“wrap_content”功能

\n\n

ViewPagerRecyclerView

\n\n

现在您可以轻松使用滚动视图,将所有项目放入其中

\n\n

如果您希望在用户滚动或某些项目在滚动中可见时产生某种效果或某些内容,您可以获取项目的位置,然后在滚动视图的\n“OnScrollChangedListener”上创建侦听器

\n