8

enter image description here

I think it can be achieved by NestedScrollingChild NestedScrollingParent.

But I can't really understand them.Who can help me out!

Product manager insists on the design.

The ScrollView contains a LinearLayout ,a "TabLayout" and a ViewPager.

The ViewPager contains 2 fragment contains RecyclerView or just only 2 RecyclerView.

When the ScrollView scroll to Bottom , the RecyclerView can scroll to Bottom.

When the RecyclerView scroll to Top , the ScrollView can scroll to Top.

<?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>
tiny sunlight
  • 6,231
  • 3
  • 21
  • 42
  • 1
    You can but its too hacky and not user friendly at all... i would recommend to redesign your app so you dont have to resort to this solution. – N Jay Nov 02 '15 at 04:32
  • The product manager persist it! – tiny sunlight Nov 02 '15 at 05:59
  • 3
    Push back and say its silly and technically wrong and against standards.... – N Jay Nov 02 '15 at 06:00
  • 1
    I don't understand what exactly you want to achieve. If you just want to have ViewPager within ScrollView, just put your whole stuff into some layout (Linear, Relative, etc) and then wrap this layout with ScrollView. Maybe take a look into `overscrollMode` for RecyclerView to have both scrolls for Recycler and for ScrollView – Alexander Tumanin Nov 16 '15 at 13:00
  • The viewpager contains 2 recyclerview. I want that them can scroll at some time. – tiny sunlight Nov 16 '15 at 13:04

2 Answers2

6

Just change your ScrollView to android.support.v4.widget.NestedScrollView

Post your xml if that doesn't work

arbrcr
  • 815
  • 4
  • 7
  • I put on my xml.There are 2 RecyclerView in ViewPager – tiny sunlight Nov 20 '15 at 16:28
  • what happens when you change ScrollView to android.support.v4.widget.NestedScrollView – arbrcr Nov 20 '15 at 16:36
  • When i scroll one RecyclerVIew from bottom to top, I want the scrollView to scroll util recyclerview bottom align screen bottom.But the recyclerView scroll directly in a small space.I am going to sleep.Bye. – tiny sunlight Nov 20 '15 at 17:06
2

ِYou can do that, but it's not good at all to use this type of layout

First you need add "wrap_content" abilty ViewPager and RecyclerView's

ViewPager and RecyclerView

Now you can use scrollview easily, put all item in it

If you want some effect or something when user scrolling or some item get visible in scrolling you can get position of item then make listener on "OnScrollChangedListener" of scrollview

Community
  • 1
  • 1
armanso
  • 144
  • 3
  • 9