Problem
So lets say I have a ViewPager (or any other view, but lets consider ViewPager) which is contained in a RelativeLayout with AlightParent top, bottom, right and left as TRUE. like:
<com.test.MyRelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/fragment_container"
>
<android.support.v4.view.ViewPager
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentBottom="true"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:id="@+id/pager"
>
</android.support.v4.view.ViewPager>
</com.test.MyRelativeLayout>
Now, I am tracking touch events on MyRelativeLayout using OnInterceptTouchEvent() and OnTouchEvent() and want to move the top edge of the ViewPager from 0 to y (will come from OnTouchEvent()) pixels from top but maintaining the bottom edge at bottom of the screen
-I explicitly require this (maintaining the bottom edge) for some reason like the ViewPager may have a ListView and if the Pager's bottom edge is below the screen's bottom edge, I may end up in cropping the ListView's content.
Now, things are not going as expected. The bottom edge of the ViewPager seems to be hanging somewhere in the screen.
Current Implementation
So lets not get into how I have implemented this callback. I am getting the correct dy on touch Movement.
public void movePager(float dy) {
mPager.setTranslationY(mPager.getTranslationY() + dy);
mPager.getLayoutParams().height = mPager.getLayoutParams().height - (int)dy;
mPager.requestLayout();
}
My expectations from people here!
Is there any better way of doing it? Any suggestions/help/modification?