1.添加按钮:
<Button
android:id="@+id/request"
android:layout_height="15dp"
android:layout_width="15dp"
android:background="@mipmap/location"
android:layout_marginLeft="10dp"
android:layout_marginStart="10dp"
android:layout_marginBottom="35dp"
android:layout_alignParentBottom="true"
android:layout_toRightOf="@+id/possition_text_view"
android:layout_toEndOf="@+id/possition_text_view" />
2.代码:
/*** 点击button位置移动到屏幕中间,尺寸为首次打开尺寸*****/ bt_request.setOnClickListener(new View.OnClickListener() { @Override public void onClick (View v) { mLocationClient.requestLocation(); LatLng ll =new LatLng(location.getLatitude(),location.getLongitude()); MapStatusUpdate u = MapStatusUpdateFactory.newLatLng(ll); baiduMap.animateMapStatus(u); baiduMap.setMapStatus(u); MapStatusUpdate u1 = MapStatusUpdateFactory.zoomTo(16f); //缩放 baiduMap.animateMapStatus(u1); } });