1

我有一个 SlidingPaneLayout,左窗格中有一个 ListView,右窗格中有一个 MapFragment。

她是我的代码:

<?xml version="1.0" encoding="utf-8"?>
<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">

    <ListView android:id="@+id/left_pane"
              android:layout_width="200dp"
              android:layout_height="match_parent"
              android:layout_gravity="left"/>

    <fragment xmlns:android="http://schemas.android.com/apk/res/android"
              android:id="@+id/map"
              android:layout_height="match_parent"
              android:layout_width="300dp"
              android:layout_weight="1"
              android:name="com.google.android.gms.maps.MapFragment"/>
</android.support.v4.widget.SlidingPaneLayout>

问题是当 SlidingPaneLayout 显示在小屏幕上时(在我的情况下小于 200dp + 300dp)。然后直到右窗格完全显示在屏幕上才能看到地图。即使左窗格在屏幕上(在 ListView 右侧可见),我也希望地图可见。

不是这样。我希望右窗格显示地图。

有可能吗,怎么做?

4

1 回答 1

0

<ListView android:id="@+id/left_pane"
          android:layout_width="200dp"
          android:layout_height="match_parent"/>

<fragment xmlns:android="http://schemas.android.com/apk/res/android"
          android:id="@+id/map"
          android:layout_height="match_parent"
          android:layout_width="300dp"
          android:name="com.google.android.gms.maps.MapFragment"/>

据我所知,android:layout_gravity="left"两者android:layout_weight="1"都是不必要的。其他一切都应该没问题。我不确定你在期待什么。我有一种感觉,看不到地图的原因是地图本身的产物。尝试用其他东西替换它。它应该显示得很好。

示例参考:探索 SlidingPaneLayout如何使用 SlidingPaneLayout

于 2013-06-10T07:46:36.730 回答