我正在使用Google Maps API for Android。下面的代码能够在右下角的工具栏的地图,当我一个标记,点击Android:Google Maps API - 更改地图工具栏的位置
googleMap.getUiSettings().setMapToolbarEnabled(true);
不过,我想这个映射工具栏出现在地图的右上角,而不是默认的底部正确的位置。
我该怎么做?
我正在使用Google Maps API for Android。下面的代码能够在右下角的工具栏的地图,当我一个标记,点击Android:Google Maps API - 更改地图工具栏的位置
googleMap.getUiSettings().setMapToolbarEnabled(true);
不过,我想这个映射工具栏出现在地图的右上角,而不是默认的底部正确的位置。
我该怎么做?
想法评论,但信誉低。所以:
据我所知,目前无法定位它。它只会出现在其默认位置。
正如Nathan所说,如果可能的话,我应该添加一些替代方案。所以,有一个解决方法:你可以禁用地图的工具栏。并可以在布局的任何位置添加appcompact的ToolBar。
参考:https://developer.android.com/reference/android/support/v7/widget/Toolbar.html
我会建议,如果可能的话,改变这一点,沿着“你不能,但这里是你可以做的事情“。 – 2015-02-24 05:32:18
当然,但一定有_something_,他可以做。 – 2015-02-24 05:38:42
对。如果你能解释什么可能是什么,那么这将是一个完全合法的答案。否则,不是那么多。 – 2015-02-24 05:39:45
这是我碰到前为如何将工具栏移动到页面底部的答案。我希望这可以帮助你。
//get reference to my location icon
View locationButton = ((View) mapFragment.getView().findViewById(Integer.parseInt("1")).
getParent()).findViewById(Integer.parseInt("2"));
// and next place it, for example, on bottom right (as Google Maps app)
RelativeLayout.LayoutParams rlp = (RelativeLayout.LayoutParams) locationButton.getLayoutParams();
// position on right bottom
rlp.addRule(RelativeLayout.ALIGN_PARENT_TOP, 0);
rlp.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE);
rlp.setMargins(0, 0, 30, 30);
编辑: 按照建议(@Andro的),这是改变地图工具栏的位置代码:
//获取参考我的位置图标
View toolbar = ((View) mapFragment.getView().findViewById(Integer.parseInt("1")).
getParent()).findViewById(Integer.parseInt("4"));
// and next place it, for example, on bottom right (as Google Maps app)
RelativeLayout.LayoutParams rlp = (RelativeLayout.LayoutParams) toolbar.getLayoutParams();
// position on right bottom
rlp.addRule(RelativeLayout.ALIGN_PARENT_TOP, 0);
rlp.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE);
rlp.setMargins(0, 0, 30, 30);
使用如下所示的地图填充:http://stackoverflow.com/a/20339849/2401535 – 2015-02-24 08:41:32
谢谢 - 这工作!直到有一个明确的方法来改变地图工具栏的位置,这将做:) – 2015-02-24 21:01:09