OSMDroid:如何设置固定图层 alpha?

问题描述 投票:0回答:1

我想设置图层的 Alpha 级别,就像在 Alpine Quest 中完成的那样,但我不知道如何设置。我在互联网上没有找到任何关于这个问题的信息。也许有人遇到过这样的事情?

我做到了

tileOverlay.setLoadingBackgroundColor(Color.TRANSPARENT);

但这不起作用,例如,对于 Google Hybrid + OSM Topo。我需要增加和减少透明度,从完全透明到完全可见。

java android-studio openstreetmap osmdroid
1个回答
0
投票

我找到了解决方案。我必须创建新的 MapView,它工作得很好:

MapView nMap = new MapView(context, tileProvider);
        nMap.setAlpha(0.55F);
        org.osmdroid.views.MapView.LayoutParams mapParams = new org.osmdroid.views.MapView.LayoutParams(
                org.osmdroid.views.MapView.LayoutParams.MATCH_PARENT,
                org.osmdroid.views.MapView.LayoutParams.MATCH_PARENT,
                null, 0, 0, 0);
        IMapController mapController = nMap.getController();
        mapController.setZoom(12);
        GeoPoint startPoint = new GeoPoint(geoPoint);
        mapController.setCenter(startPoint);
        constraintLayout.addView(nMap, mapParams);

然后,我可以创建SeekBar,并设置nMap的alpha级别。 并且不要忘记将一个 MapView 的操作与另一个/其他 MapView 相关联。

© www.soinside.com 2019 - 2024. All rights reserved.