Issue
I have a bunch of buttons on my MapView already transparent so I would like to make the built in zoom control at the bottom transparent also. The getZoomControl() on MapView is deprecated. Anyone have an idea of how to get a hold of the Buttons in the control without the getZoomControl?
Edit:
So I figured it out. It turns out that the ZoomButtonsController has a container that is just a ViewGroup. I can parse through that containers children to find the object that is an instanceof a ZoomControl, which is a down the line instance of a ViewGroup. I can parse through the children of the ZoomControl to get the ZoomButtons that it contains. getBackground() of the ZoomButton and setAlpha().
Here is my code:
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;
}
}
Solution
To my understanding it is deprecated in android.view.View but it resides in android.widget.ZoomButtonsController. Not sure if that helps. Let me know.
Answered By - jnthnjns
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.