2016-03-08 84 views

回答

0

你能提供你的XML布局?我猜你的地图与父视图匹配,其余视图在地图顶部重叠。一个简单的解决方法是,您可以将地图视图和其他视图排列成垂直的LinearLayout。如下所示:

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical" > 

    <CustomMapView 
     xmlns:android="http://schemas.android.com/apk/res/android" 
     android:layout_width="match_parent" 
     android:layout_height="0dp" 
     android:layout_weight="2" 
     android:id="@+id/mapView" /> 

    <otherView 
     android:layout_width="match_parent" 
     android:layout_height="0dp" 
     android:layout_weight="1"> 
    </otherView> 

</LinearLayout> 
+0

但是,这将阻止地图填充整个屏幕,只要滑动布局崩溃,不是吗?我正在考虑更多的程序化解决方案。无论如何,我会尝试你的解决方案,看看它是否有效。感谢你 –

+0

请注意,我使用'android:layout_weight'来衡量每个视图的高度。所以当你想用mapview填充整个屏幕时,只需在'otherView'上设置'setVisibility(View.GONE)'就可以完成工作。 –

+0

抱歉,但这并不奏效。它的真实震荡和触摸停止正常工作。 - shawn_wx –