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

问题

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

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容