美文网首页Android 异常收集地图Android知识
Scrollview嵌套百度地图MapView导致滑动有黑边或者

Scrollview嵌套百度地图MapView导致滑动有黑边或者

作者: wildma | 来源:发表于2017-07-23 15:11 被阅读253次

问题

项目中需求经常会出现Scrollview嵌套百度地图MapView,如下:
但是这样嵌套会出现Scrollview滑动的时候百度地图周边有黑边或者阴影

    <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版本之前由于使用系统GLSurfaceView导致由于系统问题出现的黑屏等,在新版地图SDK3.6.0中可使用TextureMapView作为地图视图控件,解决此类问题,但要求系统在4.0以上并且开启强制GPU渲染。

相关文章

网友评论

    本文标题:Scrollview嵌套百度地图MapView导致滑动有黑边或者

    本文链接:https://www.haomeiwen.com/subject/frrmkxtx.html