14

I need to place built-in zoom controls of MapView into position different from the default position. While it's easy to do using getZoomControls() method, this method is deprecated in recent API versions.

Does anyone has idea how to do this without calling getZoomControls()?

RedBlueThing
  • 42,006
  • 17
  • 96
  • 122
Vladimir Kroz
  • 5,237
  • 6
  • 39
  • 50
  • @Keyser nope your link answers dont help. Infact `getZoomControls` is *deprecated*, hence this question is very valid. – taxeeta Aug 14 '13 at 17:16

2 Answers2

11

I have an answer to this. I managed to reposition it with this code in the bottom left corner instead of in the middle

FrameLayout.LayoutParams zoomParams = new FrameLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT);
ZoomControls controls = (ZoomControls) getZoomButtonsController().getZoomControls();
controls.setGravity(Gravity.LEFT);
controls.setLayoutParams(zoomParams);
Etienne Lawlor
  • 6,817
  • 18
  • 77
  • 89
ludwigm
  • 3,363
  • 3
  • 28
  • 36
1

This thing does not work unless you sequence your calls correctly. This worked for me.

    map.setBuiltInZoomControls(true);
    FrameLayout.LayoutParams zoomParams = new FrameLayout.LayoutParams(
            LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT);
    ZoomControls controlls = (ZoomControls) map.getZoomButtonsController().getZoomControls();
    controlls.setGravity(Gravity.TOP);
    controlls.setLayoutParams(zoomParams);
    map.displayZoomControls(true);
    map.getController().setZoom(12);

Upvote for @ludwigm, the only answer that worked for me. Thanks.

taxeeta
  • 1,188
  • 1
  • 12
  • 25