我有一个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右侧可见),我希望地图可见。
不像this。我希望右侧窗格显示地图。
有可能,怎么样?
答案 0 :(得分: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"
都是不必要的。其他一切都应该没问题。我不确定你在期待什么。我感觉地图无法看到的原因是地图本身的产物。尝试用其他东西替换它。它应该显示得很好。
示例参考:Exploring SlidingPaneLayout,How to use the SlidingPaneLayout