Android: Google Maps API - Change Position of Maps Toolbar

Android: Google Maps API - Change position of maps toolbar

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

How to change the position of My Location Button in Google Maps using android studio

you can use this

View locationButton = ((View) mMapView.findViewById(Integer.parseInt("1")).getParent()).findViewById(Integer.parseInt("2"));
RelativeLayout.LayoutParams rlp = (RelativeLayout.LayoutParams) locationButton.getLayoutParams();
// position on right bottom
rlp.addRule(RelativeLayout.ALIGN_PARENT_TOP, 0);
rlp.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE);
rlp.setMargins(0, 180, 180, 0);

changing the position of google maps SupportMapFragment Zoom and My location controls not work

You can find Location button on map by getting parent view first and then "My Location" button as below :

// Get the "My Location" button view 
View locationButton = ((View) mapView.findViewById(1).getParent()).findViewById(2);

// get button params to place the button
RelativeLayout.LayoutParams lp = (RelativeLayout.LayoutParams) locationButton.getLayoutParams();

// place on right bottom corner
rlp.addRule(RelativeLayout.ALIGN_PARENT_TOP, 0);
rlp.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE);
rlp.setMargins(0, 0, 30, 30);

If want to resize button, you can get parameters like below :

RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(100, 100);
//.... do your editing
// To set params to button
locationButton.setLayoutParams(lp);

Changing Android Maps Toolbar animation

I did some research and I found a Stack Overflow ticket similar to you inquiry. You can disable the map's toolbar and add appcompat toolbar.
Toolbar may be placed at any arbitrary level of nesting within a view hierarchy using setSupportActionBar() method.

Here's a link were I found the solution:
Android: Google Maps API - Change position of maps toolbar

Here's a Official Google document for Toolbar:
https://developer.android.com/reference/android/support/v7/widget/Toolbar.html



Related Topics



Leave a reply



Submit