0

我的应用程序中有一个 SlidingPaneLayout,我希望它看起来或多或少像环聊一样。I show a list of elements on the left and the detail on the right pane, overlapping when an element is selected.

这就是我在 Galaxy Nexus 上看到的,这正是我想要看到的:

现在,这就是我在旧 Galaxy S 上得到的:

代码非常简单:

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

        <fragment
            android:id="@+id/list_pane"
            android:name="com.towers.hotelsclickpoc.ResultsCardsFragment"
            android:layout_width="400dp"
            android:layout_height="match_parent"
            android:layout_weight="40"
            android:layout_gravity="left"></fragment>

        <fragment
            android:id="@+id/content_pane"
            android:name="com.towers.hotelsclickpoc.DetailsFragment"
            android:layout_width="450dp"
            android:layout_height="match_parent"
            android:layout_weight="45"
            android:paddingLeft="16dp"
            android:paddingRight="16dp"></fragment>

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

如何使两个设备上的布局看起来非常相似?如您所见,我尝试添加一些权重,但没有奏效。

4

1 回答 1

0

好的,看来我设法修复了它。

SlidingPaneLayout 的内部现在看起来像这样:

        <fragment
        android:id="@+id/list_pane"
        android:name="com.towers.hotelsclickpoc.ResultsCardsFragment"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_gravity="left"></fragment>

    <fragment
        android:id="@+id/content_pane"
        android:name="com.towers.hotelsclickpoc.DetailsFragment"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:paddingLeft="16dp"
        android:paddingRight="16dp"></fragment>

似乎两个片段上的 layout_width="match_parent" 都成功了。

我希望这对其他人有帮助。

于 2014-04-11T09:14:54.730 回答