The only way to have a custom button like the zoom buttons in Android map is to make one of your own. The way I did this is to have an XML drawable assigned to the ImageButton. It is pretty simple.

Then assign this as background to the ImageButton widget. Your image should be assigned to the source attribute.

That’s it!

So you have a ViewPager and your first page is an Android map. When you add or replace a new Fragment on the next page, your map resets when you go back to the first page.

Sadly, there is no way to retain its state. The only way you can do is to keep a reference on the map’s position by calling googleMap.getCameraPosition() and saving that in onSaveInstanceState() and restoring it in onCreate() or wherever.

Then you can reposition the map’s position and its zoom level by calling googleMap.moveCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));

Related Posts Plugin for WordPress, Blogger...