I'm trying to get the zoom controls to show up in a mapview
, the following code almost works, but the zoom controls appear in the top left of the mapview
, not the bottom center like I'm specifying via setGravity()
. Can someone enlighten me as to what I'm missing?
zoomView = (LinearLayout) mapView.getZoomControls();
zoomView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,ViewGroup.LayoutParams.WRAP_CONTENT));
zoomView.setGravity(Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL);
mapView.addView(zoomView);
These views/layouts are all constructed programmatically, there is no layout file to tweak.
Add the following line to the OnCreate()
method of your MapView
Class:
view.setBuiltInZoomControls(true);