我MapView已经透明的上有一堆按钮,所以我想让底部的内置缩放控件也透明。getZoomControl()on已MapView弃用。任何人都知道如何Buttons在没有 的情况下掌握控制权getZoomControl?
编辑:
所以我想通了。事实证明,它ZoomButtonsController有一个容器,它只是一个ViewGroup. 我可以通过该容器子项进行解析,以找到一个 instanceof a 的对象ZoomControl,它是 a 的下线实例ViewGroup。我可以解析 的子项ZoomControl以获取ZoomButtons它包含的内容。 getBackground()的ZoomButton和setAlpha()。
这是我的代码:
android.widget.ZoomButtonsController zbc = mapView.getZoomButtonsController();
ViewGroup container = zbc.getContainer();
for (int i = 0; i < container.getChildCount(); i++) {
View child = container.getChildAt(i);
if (child instanceof ZoomControls) {
ViewGroup zoomC = (ViewGroup)child;
for (int j = 0; j < zoomC.getChildCount(); j++) {
View btn = zoomC.getChildAt(j);
if ( btn instanceof ZoomButton ) {
((ZoomButton)btn).getBackground().setAlpha(120);
}
}
break;
}
}