Android: Google Maps API – Change position of maps toolbar

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);

Leave a Comment