0

我将此布局用于两个面板 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开始时总是显示为最大化,我希望左边首先显示,如果我交换它们,那么左边首先显示,但滑动方向错误。

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

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

 +---------------------+---+ 
 |                     |   | 
 |                     |   | 
 |                     |   | 
 |                     |   | 
 |                     |   | 
 |                     |   | 
 |                     |   | 
 |                     |   | 
 |                     |   | 
 |                     |   | 
 |                     |   | 
 |                     |   | 
 |                     |   | 
 |                     |   | 
 |                     |   | 
 |                     |   | 
 +---------------------+---+ 
4

1 回答 1

1

showPane()在调用 之后调用SlidingPaneLayout,例如在onCreate()您的活动中setContentView()。我不知道仅在布局文件中表达这一点的方法。

FWIW,这里是一个示例项目,展示了这种用法showPane(),加上 BACK 按钮处理(如果显示右窗格,则 BACK 应该显示左窗格,按照经典的主从模式样式)。

于 2014-08-01T16:01:33.973 回答