Tabs in ViewPager inside vertical ScrollView will not scroll vertically

I have tabs in a ViewPager that is inside a vertical ScrollView. Horizontal clicks completed successfully. When I try to do vertical clicks, nothing happens.

FragmentActivity layout

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

<RelativeLayout
    android:id="@+id/RelativeLayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/border_white"
    android:orientation="vertical">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:layout_alignParentBottom="true"
        android:id="@+id/llButtons">
        <Button
            android:id="@+id/btnBack"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="@string/all"
            android:onClick="onClickAll"
            style="@style/button.blue"
            android:layout_weight="1" />

    </LinearLayout>

    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_above="@id/llButtons"
        android:fillViewport="true">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical">

            <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
                xmlns:app="http://schemas.android.com/apk/res-auto"
                android:orientation="vertical" android:layout_width="match_parent"
                android:layout_height="match_parent">

                <com.astuetz.PagerSlidingTabStrip
                    android:id="@+id/tabs"
                    android:layout_width="match_parent"
                    android:layout_height="48dip"
                    style="@style/PagerSlidingTabStrip"
                    app:pstsShouldExpand="true"/>

                <android.support.v4.view.ViewPager
                    android:id="@+id/pager"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"/>

            </LinearLayout>

        </LinearLayout>
    </ScrollView>

</RelativeLayout>
</LinearLayout>

      

Perhaps I have a conflict between ScrollView and ViewPager.

UPDATE The solution with ScrollViews in Fragments is nice, but I want something like this:

User can see tabsUser can't see tabs

The user cannot see the contents of the tab in the second screenshot.

+3


source to share


2 answers


Do you really need to have a pager view inside the scrollview? My suggestion is to use scrollviews as layout containers for viewpager fragments.



0


source


I think you should change your layout this way:

since you don't have a widget inside the scrollView and I think everything in your fragment's layouts moves your scrollview to the layout of every fragment you submit to the viewer and make it as root. so each slice is scrolled vertically and you can also change them with the viewpager.



We hope for help!

0


source







All Articles