如何使用Android Studio更改“我的位置”按钮在Google地图中的位置
问题内容:
我正在使用谷歌地图,我需要更改“我的位置”(当前位置按钮)的位置。当前当前位置按钮在右上角。因此,请帮助我如何在Google地图屏幕上重新定位当前位置按钮。提前致谢。
我的示例代码:
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);