I'm using the Google Maps API for Android. The following code enables the maps toolbar in the bottom right corner when I click on a Marker
googleMap.getUiSettings().setMapToolbarEnabled(true);
However, I'd like this maps toolbar to appear in the TOP RIGHT corner of the map, rather than the default bottom right position.
How would I do this?
Thought of commenting, But has low reputation. So:
As far as I know, there is no way to position it for now. It'll appear at its default position only.
As Nathan said I should add some alternative if possible. So,There is a work around: You can disable the map's toolbar. and can add appcompact's ToolBar anywhere in the layout.
Reference : https://developer.android.com/reference/android/support/v7/widget/Toolbar.html
This is an answer that i came across before as to how to move the toolbar to the bottom of the page. I hope this helps you.
//get reference to my location icon
View locationButton = ((View) mapFragment.getView().findViewById(Integer.parseInt("1")).
getParent()).findViewById(Integer.parseInt("2"));
// and next place it, for example, on bottom right (as Google Maps app)
RelativeLayout.LayoutParams rlp = (RelativeLayout.LayoutParams) locationButton.getLayoutParams();
// position on right bottom
rlp.addRule(RelativeLayout.ALIGN_PARENT_TOP, 0);
rlp.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE);
rlp.setMargins(0, 0, 30, 30);
EDIT:
As per suggestions (of @Andro) this is the code to change the location of the map toolbar:
//get reference to my location icon
View toolbar = ((View) mapFragment.getView().findViewById(Integer.parseInt("1")).
getParent()).findViewById(Integer.parseInt("4"));
// and next place it, for example, on bottom right (as Google Maps app)
RelativeLayout.LayoutParams rlp = (RelativeLayout.LayoutParams) toolbar.getLayoutParams();
// position on right bottom
rlp.addRule(RelativeLayout.ALIGN_PARENT_TOP, 0);
rlp.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE);
rlp.setMargins(0, 0, 30, 30);