I have been trying to left align My Location button on google map as its aligned right by default.
I've seen solution code here, but isn't helped much.
And tried the code following:
SupportMapFragment mapFragment = ((SupportMapFragment)
getChildFragmentManager().findFragmentById(R.id.fragmentMap));
View myLocationButton = mapFragment.getView().findViewById(0x2);
if (myLocationButton != null && myLocationButton.getLayoutParams() instanceof RelativeLayout.LayoutParams) {
// location button is inside of RelativeLayout
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) myLocationButton.getLayoutParams();
params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
params.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, 0);
params.addRule(RelativeLayout.ALIGN_PARENT_TOP, 0);
// Update margins, set to 10dp
final int margin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 10, getResources().getDisplayMetrics());
params.setMargins(margin, margin, margin, margin);
myLocationButton.setLayoutParams(params);
}