如何使用android studio更改我的位置按钮在谷歌地图中的位置 [英] How to change the position of My Location Button in Google Maps using android studio

查看:68
本文介绍了如何使用android studio更改我的位置按钮在谷歌地图中的位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在处理谷歌地图,我需要更改我的位置(当前位置按钮)的位置.当前当前位置按钮位于右上角.所以请帮助我如何在谷歌地图屏幕上重新定位当前位置按钮.提前致谢.

I am working on google maps, and I need to change position of My Location(current location button). Presently current location button is at top-right side. So please help me how to re-position the current location button on google maps screen. Thanks in advance.

我的示例代码:

final GoogleMap googleMap = mMapView.getMap();
googleMap.setMyLocationEnabled(true);

推荐答案

你可以使用这个

View locationButton = ((View) mMapView.findViewById(Integer.parseInt("1")).getParent()).findViewById(Integer.parseInt("2"));
RelativeLayout.LayoutParams rlp = (RelativeLayout.LayoutParams) locationButton.getLayoutParams();
// position on right bottom
rlp.addRule(RelativeLayout.ALIGN_PARENT_TOP, 0);
rlp.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE);
rlp.setMargins(0, 180, 180, 0);

这篇关于如何使用android studio更改我的位置按钮在谷歌地图中的位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆