如何使用android studio更改Google地图中“我的位置”按钮的位置

问题描述:

我在Google地图上工作,我需要更改我的位置(当前位置按钮)的位置。目前的位置按钮位于右上角。所以请帮助我如何重新定位谷歌地图屏幕上的当前位置按钮。

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.

我的示例代码:

my sample code:

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