問題
項(xiàng)目中需求經(jīng)常會出現(xiàn)Scrollview嵌套百度地圖MapView面殖,如下:
但是這樣嵌套會出現(xiàn)Scrollview滑動的時(shí)候百度地圖周邊有黑邊或者陰影
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="none">
<!--其他組件-->
<com.baidu.mapapi.map.MapView
android:id="@+id/map_mapview"
android:layout_width="match_parent"
android:layout_height="@dimen/dimen_154dp"
android:clickable="true"/>
</ScrollView>
解決
將MapView換成TextureMapView即可。如下:
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="none">
<!--其他組件-->
<com.baidu.mapapi.map.TextureMapView
android:id="@+id/map_mapview"
android:layout_width="match_parent"
android:layout_height="@dimen/dimen_154dp"
android:clickable="true"/>
</ScrollView>
原因
3.6.0版本之前由于使用系統(tǒng)GLSurfaceView導(dǎo)致由于系統(tǒng)問題出現(xiàn)的黑屏等赂毯,在新版地圖SDK3.6.0中可使用TextureMapView作為地圖視圖控件,解決此類問題蛀序,但要求系統(tǒng)在4.0以上并且開啟強(qiáng)制GPU渲染欢瞪。