What is the correct way to change the appearance of MapView controls in Android?

What is the correct way to change the appearance of MapView controls in Android?

I want to move the zoom button from new google maps.

enter image description here

+6
source share
2 answers

I have done it. By default, the controls go to the bottom of the map, and I wanted it to be the top of the map. I used this.

<com.google.android.maps.MapView android:layout_below="@+id/layout_zoom" android:id="@+id/mapview" android:layout_width="fill_parent" android:layout_height="fill_parent" android:clickable="true" android:apiKey="key" /> <ZoomControls android:id="@+id/zoomControls" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentTop="true" android:layout_centerHorizontal="true"></ZoomControls> 

then the MapActivity class has zoom controls

  MapView mp = (MapView) findViewById(R.id.mapview); ZoomControls zoomControls = (ZoomControls) findViewById(R.id.zoomControls); zoomControls .setOnZoomInClickListener(new ZoomControls.OnClickListener() { public void onClick(View v) { mp.getController().zoomIn(); } }); zoomControls .setOnZoomOutClickListener(new ZoomControls.OnClickListener() { public void onClick(View v) { mp.getController().zoomOut(); } }); 

You can also configure these listeners to your own button. hope this helps.

+2
source

Using the MapView API, disable standard zoom controls, using the layout, overlay the desired widgets, attach their click event listeners to the MapController setZoomLevel .

0
source

Source: https://habr.com/ru/post/901492/


All Articles