S
S
stormit2015-06-09 16:50:38
Android
stormit, 2015-06-09 16:50:38

Why does ImageView position reset when switching ViewPager?

there is such markup

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
    android:layout_height="match_parent"
     >

<android.support.v4.view.ViewPager
    android:id="@+id/pager"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
</android.support.v4.view.ViewPager>
    <ImageView
        android:layout_centerInParent="true"
        android:id="@+id/touchImg"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:src="@drawable/robo"
        android:scaleType="center" />
</RelativeLayout>

the meaning is this, by touching and holding on the picture, I move the picture behind my finger, and at a certain offset (for example, to the right by 200 dp) I programmatically switch the viewpager (without releasing the tap)
mViewPager.setCurrentItem(mViewPager.getCurrentItem()+1,true);

the picture at the time of switching the viewpager moves to the center (default position) for a fraction of a moment and then jumps back to the old position (under the finger, shifted). Why does this happen with the picture, is it supposed to not respond to the viewpager at all ?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question