4

I have requirement like play store app where there is view pager with images and videos and scroll to view details .Unfortunately when user scrolls the scroll is jumpy but if i remove the scrollview the view pager works perfectly fine .

The layout look and feel is something like this http://cl.ly/MBRB

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"  android:fillViewport="true">

<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical" >



    <RelativeLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="160dp"
        android:background="@drawable/loading_image"
        android:gravity="top"
        android:orientation="vertical" >

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

        <com.viewpagerindicator.CirclePageIndicator
            android:id="@+id/titles"
            style="@style/CirclePageIndicator"
            android:layout_alignParentBottom="true"
            android:padding="10dip"
            android:paddingBottom="10dp" />
    </RelativeLayout>

    <include layout="@layout/app_screen_menu" />
</LinearLayout>
</ScrollView>

Btw i am loading images from server .

Thanks

Preethi
  • 2,112
  • 7
  • 38
  • 54
  • can you post a screenshot of your layout? – FoamyGuy Jan 14 '13 at 20:46
  • The Play Store does not use a layout like this. The scrollable content is inside the pages, not outside the pager. You can tell this by actually using the Play Store app -- the indicator at the top does not scroll, as it would with your approach. I suspect that it also does not use a `ScrollView`, but rather some form of `AdapterView` (possibly a custom one). – CommonsWare Jan 14 '13 at 20:52
  • Edited with the image http://cl.ly/MBRB – Preethi Jan 14 '13 at 20:52

1 Answers1

6

You are using 2 scrollisteners

  • A viewpager uses a scrolllistener
  • A scrollview uses a scrolllistener

These two scrollistener are fighting for the ScrollEvent. You can solve this by implementing onInterceptTouch. In this method you can decide who wins the fight over the ScrollEvent

Take a look at this protected post regarding a similair issue containing 2 scrollviews

Tobrun
  • 18,291
  • 10
  • 66
  • 81