【问题标题】:How to reposition built-in zoom controls in MapView?如何重新定位 MapView 中的内置缩放控件?
【发布时间】:2010-10-27 16:17:21
【问题描述】:

我需要将 MapView 的内置缩放控件放置在与默认位置不同的位置。 虽然使用 getZoomControls() 方法很容易,但在最近的 API 版本中已弃用此方法。

有没有人知道如何在调用 getZoomControls() 的情况下做到这一点?

【问题讨论】:

  • @Keyser 不,您的链接答案没有帮助。事实上getZoomControls弃用,因此这个问题非常有效。

标签: android android-mapview


【解决方案1】:

我有一个答案。我设法用左下角而不是中间的代码重新定位它

FrameLayout.LayoutParams zoomParams = new FrameLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT);
ZoomControls controls = (ZoomControls) getZoomButtonsController().getZoomControls();
controls.setGravity(Gravity.LEFT);
controls.setLayoutParams(zoomParams);

【讨论】:

    【解决方案2】:

    除非您正确排序呼叫,否则此操作不起作用。这对我有用。

        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);
    

    支持@ludwigm,这是唯一对我有用的答案。谢谢。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2010-09-20
      • 1970-01-01
      • 1970-01-01
      • 2012-06-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多