我在我的MapView
上有一堆已經透明的按鈕,所以我想讓底部的變焦控制內置透明。 MapView
上的getZoomControl()
已棄用。如果沒有getZoomControl
,任何人都有想法如何在控制系統中保留Buttons
?如何在MapView透明上製作ZoomControl?
編輯:
所以我想通了。事實證明,ZoomButtonsController
有一個容器,只是一個ViewGroup
。我可以通過容器中的孩子來解析這個對象,該對象是一個ZoomControl
的實例,它是ViewGroup
的一個實例。我可以通過ZoomControl
的孩子解析得到它包含的ZoomButtons
。 ZoomButton
和setAlpha()
的getBackground()
。
這裏是我的代碼:
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;
}
}