Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google maps android api: moving the compass button

I see that it's possible to set margins for the UI, also it's possible to disable the button.

But can we move compass button to a different location rather then top left?

Google maps app has it in the top right corner, which made me think that it's possible.

like image 335
Oleg Filimonov Avatar asked Jan 27 '16 20:01

Oleg Filimonov


1 Answers

I just had the same problem and solved it like this:

/* access compass */
ViewGroup parent = (ViewGroup) mMapView.findViewById(Integer.parseInt("1")).getParent();
View compassButton = parent.getChildAt(4);
/* position compass */
RelativeLayout.LayoutParams CompRlp = (RelativeLayout.LayoutParams) compassButton.getLayoutParams();
CompRlp.addRule(RelativeLayout.ALIGN_PARENT_TOP, 0);
CompRlp.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE);
CompRlp.setMargins(0, 180, 180, 0);

This moves the compass a bit further away from the top

like image 79
arne.z Avatar answered Sep 20 '22 02:09

arne.z