我的应用程序中有一个SlidingPaneLayout,我希望它看起来或多或少像Hangout一样。我在左侧显示了一个元素列表,在右侧窗格中显示了详细信息,当选择一个元素时,它们会重叠。
这是我在我的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>
如何才能使布局在两个设备上看起来完全相同?正如你所看到的,我试着添加一些权重,但不起作用。
发布于 2014-04-11 17:14:55
好的,看起来我设法把它修好了。
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“似乎都起到了作用。
我希望这能对其他人有所帮助。
https://stackoverflow.com/questions/22993625
复制相似问题