【问题标题】:can i create a nestedScroll Layout like this?我可以像这样创建嵌套的滚动布局吗?
【发布时间】:2016-02-01 22:05:30
【问题描述】:

我认为可以通过NestedScrollingChildNestedScrollingParent来实现。

但我真的无法理解它们。谁能帮帮我!

产品经理坚持设计。

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>

【问题讨论】:

  • 你可以,但它太老套了,而且对用户不友好......我建议重新设计你的应用程序,这样你就不必求助于这个解决方案了。
  • 产品经理坚持下去!
  • 回击说它愚蠢且技术上错误且违反标准......
  • 我不明白你到底想达到什么目的。如果您只想在 ScrollView 中使用 ViewPager,只需将所有内容放入某个布局(线性、相对等)中,然后使用 ScrollView 包装此布局。也许看看 overscrollMode 的 RecyclerView 让 Recycler 和 ScrollView 都有滚动
  • viewpager 包含 2 个 recyclerview。我希望他们可以在某个时间滚动。

标签: android scrollview android-recyclerview nestedscrollview


【解决方案1】:

只需将您的 ScrollView 更改为 android.support.v4.widget.NestedScrollView

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

【讨论】:

  • 我放上我的xml。ViewPager中有2个RecyclerView
  • 将 ScrollView 更改为 android.support.v4.widget.NestedScrollView 会发生什么
  • 当我从下到上滚动一个RecyclerVIew时,我希望scrollView滚动util recyclerview底部对齐屏幕底部。但是recyclerView直接在一个小空间滚动。我要睡觉了。再见。
【解决方案2】:

ِ你可以这样做,但是使用这种类型的布局一点都不好

首先你需要添加“wrap_content”能力ViewPager和RecyclerView的

ViewPagerRecyclerView

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

如果您想要在用户滚动时获得一些效果或某些东西,或者某些项目在滚动中可见,您可以获取项目的位置,然后让监听器打开 滚动视图的“OnScrollChangedListener”

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2023-03-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-08-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多