Scrollview inside viewpager scroll vertical not working

有些话、适合烂在心里 提交于 2020-01-04 05:31:11

问题


Below is my code but its not working properly, want a viewpager with scrollview in all fragment. Scrolling of the scrollview is not working,facing problem from last 2 hrs and not getting a solution.Please help me its urgent.Not able to solve this issue i tried adding nested scrollview but it is also not working.

<?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">

<LinearLayout
    android:id="@+id/toolbar_ll"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content">

    <android.support.v7.widget.Toolbar
        android:id="@+id/toolbar_myjeenees"
        android:layout_width="match_parent"
        android:layout_height="56dp"
        android:background="@android:color/white"
        android:minHeight="?attr/actionBarSize">

        <TextView
            android:id="@+id/toolbarShuffle"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:text="Shuffle Money"
            android:textColor="@color/black"
            android:textSize="18sp" />

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

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

    <LinearLayout
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:orientation="vertical">

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:padding="5dp"
            android:text="UserName"
            android:textSize="25sp" />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:padding="5dp"
            android:text="May 15,Birthday" />

    </LinearLayout>

    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:layout_marginRight="10dp"
        android:background="@mipmap/ic_forward" />
</LinearLayout>


<com.android.jeenees.utils.CustomScrollView
    android:id="@+id/scrollView"
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="1"
    android:fillViewport="true"
    >

    <android.support.v4.view.ViewPager
        android:id="@+id/shufflePager"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@android:color/white" />
</com.android.jeenees.utils.CustomScrollView>
<!--</LinearLayout>-->

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

    <ImageButton
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_weight="1"
        android:background="@color/colorPrimary"
        android:padding="10dp"
        android:src="@mipmap/ic_action_tick" />

    <ImageButton
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_weight="1"
        android:background="@color/colorPrimary"
        android:padding="10dp"
        android:src="@mipmap/ic_back" />
</LinearLayout>

<?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:fillViewport="true"
android:orientation="vertical">

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_margin="10dp"
    android:layout_weight="1"
    android:orientation="vertical">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1"
        android:fillViewport="true">

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

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_weight="1"
                android:orientation="vertical">

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="0dp"
                    android:layout_weight="1"
                    android:gravity="center"
                    android:orientation="horizontal">

                    <TextView
                        android:id="@+id/firstwish"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="IPhone 5s" />

                    <View
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_weight="1" />

                    <TextView
                        android:id="@+id/costfirst"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="Rs 5300/32777" />
                </LinearLayout>

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="0dp"
                    android:layout_weight="1"
                    android:gravity="center"
                    android:orientation="vertical">

                    <SeekBar
                        android:id="@+id/seekfirst"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:max="100"
                        android:maxHeight="10dp"
                        android:progress="50"
                        android:progressDrawable="@drawable/progress_draw"
                        android:splitTrack="false"
                        android:thumb="@mipmap/ic_thumb"></SeekBar>
                </LinearLayout>
            </LinearLayout>

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_weight="1"
                android:orientation="vertical">

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="0dp"
                    android:layout_weight="1"
                    android:gravity="center"
                    android:orientation="horizontal">

                    <TextView
                        android:id="@+id/secondwish"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="IPhone 5s" />

                    <View
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_weight="1" />

                    <TextView
                        android:id="@+id/costsecond"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="Rs 5300/32777" />
                </LinearLayout>

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="0dp"
                    android:layout_weight="1"
                    android:gravity="center"
                    android:orientation="vertical">

                    <SeekBar
                        android:id="@+id/seeksecond"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:max="100"
                        android:maxHeight="10dp"
                        android:progress="50"
                        android:progressDrawable="@drawable/progress_draw"
                        android:splitTrack="false"
                        android:thumb="@mipmap/ic_thumb"></SeekBar>
                </LinearLayout>
            </LinearLayout>

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_weight="1"
                android:orientation="vertical">

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="0dp"
                    android:layout_weight="1"
                    android:gravity="center"
                    android:orientation="horizontal">

                    <TextView
                        android:id="@+id/thirdwish"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="IPhone 5s" />

                    <View
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_weight="1" />

                    <TextView
                        android:id="@+id/costthird"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="Rs 5300/32777" />
                </LinearLayout>

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="0dp"
                    android:layout_weight="1"
                    android:gravity="center"
                    android:orientation="vertical">

                    <SeekBar
                        android:id="@+id/seekthird"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:max="100"
                        android:maxHeight="10dp"
                        android:progress="50"
                        android:progressDrawable="@drawable/progress_draw_red"
                        android:splitTrack="false"
                        android:thumb="@mipmap/ic_red_thumb"></SeekBar>
                </LinearLayout>
            </LinearLayout>
        </LinearLayout>
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="0.5"
        android:gravity="center"
        android:orientation="vertical">

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:padding="10dp"
            android:text="Rs 1700"
            android:textSize="25sp" />


        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:padding="10dp"
            android:text="Released Money"
            android:textSize="25sp" />

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:orientation="horizontal">

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:background="@color/colorPrimary"
                android:drawableLeft="@mipmap/ic_actin_add"
                android:gravity="center"
                android:padding="15dp"
                android:text="Top Up"
                android:textColor="@android:color/white" />
        </LinearLayout>
    </LinearLayout>
</LinearLayout>


回答1:


Each view take parent event first if your view pager is swipe horizonatly for change the page tab than you can not use horizonatl scroll in child fragment . It is not write practice you can arrange your page content as vertical and use vertical scroll view. Or second option you will have to disable swipe event for view pager and only tab click is uesd to change page than you can use horizontal scroll view.



来源:https://stackoverflow.com/questions/34491117/scrollview-inside-viewpager-scroll-vertical-not-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!