SlidingPanelLayout默认面板

时间:2014-08-01 14:46:24

标签: android layout slidingpanelayout

我将此布局用于两个面板UI:

<?xml version="1.0" encoding="utf-8"?>

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

    <fragment
        android:id="@+id/leftPane"
        android:name="com.sample.SearchFragment"
        android:layout="@layout/search_fragment"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_gravity="left"
        >
    </fragment>


    <fragment
        android:id="@+id/rightPane"
        android:name="com.sample.DetailFragment"
        android:layout="@layout/detail_fragment"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_gravity="right"
        >
    </fragment>

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

问题是,rightPane总是在开始时显示为最大化,我希望左边首先显示,如果我交换它们,那么左边首先显示,但滑动工作方向错误。< / p>

我希望它像环聊应用。我要更改哪个设置?

I want it to show up at the start like so :

 +---------------------+---+ 
 |                     |   | 
 |                     |   | 
 |                     |   | 
 |                     |   | 
 |                     |   | 
 |                     |   | 
 |                     |   | 
 |                     |   | 
 |                     |   | 
 |                     |   | 
 |                     |   | 
 |                     |   | 
 |                     |   | 
 |                     |   | 
 |                     |   | 
 |                     |   | 
 +---------------------+---+ 

1 个答案:

答案 0 :(得分:1)

在致电showPane()后,致电SlidingPaneLayout上的onCreate(),例如您活动的setContentView()。我不知道如何在布局文件中表达这一点。

FWIW,here is a sample project显示showPane()的使用,加上BACK按钮处理(如果显示右窗格,则BACK应按照经典的主 - 细节图案样式显示左窗格)。