3

他のビューの上に画面全体を埋めて非表示にする ViewPager を表示したいと思います。この 2 番目のビューは画面の下部に設定され、ユーザーが ViewPager で下から上にフリングを実行すると表示されます。2 番目のビューが表示されるまで、ViewPager を一番上に移動するアニメーションを実行します。

実際には、2 番目のビューを重ねることはできません。ビューは常に表示され、ViewPager によって非表示になることはありません。xml でレイアウトを構成するために使用する順序 (ViewPager を最初に宣言してから 2 番目のビュー、またはその逆) や、RelativeLayout または FrameLayout を使用する順序は何でも構いません。

ここに私が使用するコードがあります:

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

1 に答える 1

2

私は次の投稿に従いました: Androidでビューをオーバーラップし、ビューを次の xml 構成とオーバーラップさせることができました:

<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>
于 2012-03-07T14:09:43.877 に答える