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

版权声明:本文为wildma原创文章,转载请注明出处! https://blog.csdn.net/Alpha58/article/details/72872611

问题

项目中需求经常会出现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渲染。

猜你喜欢

转载自blog.csdn.net/Alpha58/article/details/72872611