Android谷歌地图中的位置按钮

时间:2017-05-13 09:50:30

标签: java android

2 个答案:

答案 0 :(得分:0)

使用map对象调用map.setlocationEnabled(true);

答案 1 :(得分:0)

在地图上显示位置按钮

SupportMapFragment supportMapFragment =(SupportMapFragment)getSupportFragmentManager()。findFragmentById(R.id.map_fragment);         supportMapFragment.getMap()getUiSettings()setZoomControlsEnabled(假)。;         supportMapFragment.getMap()getUiSettings()setMyLocationButtonEnabled(真)。。         supportMapFragment.getMap()setMyLocationEnabled(真);

您也可以更改按钮位置。

查看locationButton =((查看)supportMapFragment.getView()。findViewById(Integer.parseInt(" 1"))。getParent())。findViewById(Integer.parseInt(" 2&#) 34));         RelativeLayout.LayoutParams rlp =(RelativeLayout.LayoutParams)locationButton.getLayoutParams();         //位于右下角         rlp.addRule(RelativeLayout.ALIGN_PARENT_TOP,0);         rlp.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM,RelativeLayout.TRUE);         rlp.setMargins(0,0,180,80);