Question

I would like to display a ViewPager that shall fill the whole screen over an other view, hidding it. This second view shall be set at the bottom of the screen and shall be displayed when the user perform a fling from bottom to top on the ViewPager ; it shall perform an animation that will move the ViewPager to the top until the second view is displayed.

The fact is I cannot overlap the second view, it is always displayed and never hidden by the ViewPager. Whatever the order I use to configure my layout in the xml (declare ViewPager first and then the second view, or the inverse) or whatever I use RelativeLayout or FrameLayout.

Here is the code I use :

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

    <LinearLayout
        android:id="@+id/hlist"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_alignParentLeft="true"
        android:background="@drawable/bg_shelf"
        android:orientation="horizontal" >
    </LinearLayout>

    <android.support.v4.view.ViewPager
        android:id="@+id/pager"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true" />

</RelativeLayout>
Was it helpful?

Solution

I followed the following post : overlapping views in Android and I was able to overlap my view with the following xml configuration :

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

    <LinearLayout
        android:id="@+id/hlist"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_alignParentLeft="true"
        android:layout_gravity="center_vertical"
        android:background="@drawable/bg_shelf"
        android:orientation="horizontal" >
    </LinearLayout>


    <android.support.v4.view.ViewPager
        android:id="@+id/pager"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_alignBottom="@id/hlist"
        android:layout_alignLeft="@id/hlist"
        android:layout_alignRight="@id/hlist"/>

</RelativeLayout>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top