0

私は苦労しましSlidingPaneLayoutた。画像に示されているような3つのパネルでアクティビティを作成しようとしています: ここに画像の説明を入力

パネル 2 をデフォルトで表示したい場合、ユーザーが左から右にスワイプするとパネル 1 が開き、右から左にスワイプするとパネル 3 が開きます。ビューをSlidingPaneLayout最後に追加すると、デフォルトで表示されます。どのビューを開始ビューにするかを設定する方法はありますか? ここに私のレイアウトxmlがあります:

<android.support.v4.widget.SlidingPaneLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/side_menu_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    <ListView android:id="@+id/left_drawer"
        android:layout_width="240dp"
        android:layout_height="match_parent"
        android:choiceMode="singleChoice"
        android:divider="@android:color/transparent"
        android:dividerHeight="0dp"
        android:background="@color/gray"/>
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@color/oliveGreen">
    </LinearLayout>
    <ListView android:id="@+id/right_drawer"
        android:layout_width="240dp"
        android:layout_height="match_parent"
        android:layout_marginRight="0dp"
        android:layout_marginEnd="0dp"
        android:choiceMode="singleChoice"
        android:divider="@android:color/transparent"
        android:dividerHeight="0dp"
        android:background="@color/gray"/>
</android.support.v4.widget.SlidingPaneLayout>

この構成rightDrawerでは、開始ビューとして表示されます。その右側に表示LinearLayoutして設定したい。rightDrawr私はそれを明確にしたことを願っています。何か助けていただければ幸いです。前もって感謝します。

4

2 に答える 2

0

カスタム アダプタを設定し、そこで定義します。 https://github.com/survivingwithandroid/Surviving-with-android/tree/master/SlidingPaneLayout/src/com/survivingwithandroid/slidingpanelayout/adapter

于 2015-05-18T20:32:39.647 に答える
0

編集:

のドキュメントを読み直したところ、SlidingPaneLayout2 ビューのみを対象としているようです。

ページ 0 とページ 2 を小さくするために、アダプタの をViewPager使用してこのレイアウトを偽造しようとするかもしれません。float getPageWidth(int)それがあなたの要件に合うかどうかはわかりません。

それ以外にできる唯一のことは、SlidingPaneLayout ソース コードを確認し、それを変更してleft/right、引き出しのように重力で動作するようにすることです。

元の答え

私はあなたの問題を理解していないかもしれません。

gravityパネルがどちら側になるかを伝えるために使用するだけです:

<android.support.v4.widget.SlidingPaneLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/side_menu_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

   <View android:gravity="left" />
   <View android:gravity="right />
   <View  /> << that's the one always visible.

</android.support.v4.widget.SlidingPaneLayout>

このような。

于 2015-05-18T20:32:44.857 に答える