我的布局结构简单:
DrawerLayout
\-- FrameLayout // @+id/fragment_container
\-- ListView // @+id/drawer_list
通过点击任何抽屉项目,我将FragmentTransaction.replace()
中的片段插入/替换为具有相应片段实例的R.id.fragment_container
。其中一个片段包含MapView
。
它在不同设备上存在渲染问题,但同时DDMS向我显示正确的屏幕截图。
EDITED
问题出现在这些设备上:
此类设备上有no issue
:
有人可以帮我理解并解决这个问题吗?
见图片:
华为U9508 ,Android 4.0.4(API 15)
HTC Desire A9191 ,Android 2.3.5(API 10)
DDMS
EDITED
活动布局:
<?xml version="1.0" encoding="utf-8"?>
<DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/drawer"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<!-- The main content view -->
<FrameLayout
android:id="@+id/fragment_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
<!-- The navigation drawer -->
<ListView
android:id="@+id/drawer_list"
android:layout_width="240dp"
android:layout_height="match_parent"
android:orientation="vertical"
/>
</DrawerLayout>
片段布局:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<!-- other views here -->
<com.google.android.gms.maps.MapView
android:id="@+id/consumer_profile_map"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
</RelativeLayout>
答案 0 :(得分:27)
所以,我找到了解决方法:只需将MapView
包装到容器中,然后在上面放置空View
。感谢这个答案:https://stackoverflow.com/a/16231935/1891118
我的更新布局:
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<com.google.android.gms.maps.MapView
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
<View
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
</FrameLayout>