Reputation: 1049
I want to add a view on top of mapview that does not move when I move the map view. The mapview can be zoomed in or zoomed out but the view should be stationary at the center of the map view. Please guide me how to do it.
Thanks
Upvotes: 0
Views: 240
Reputation: 9019
This should be your xml code
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.google.android.gms.maps.MapView
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</RelativeLayout>
Then in your Activity do this
RelativeLayout.LayoutParams layoutParams = new
RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
layoutParams.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE);
relativeLayout.addView(yourView, layoutParams);
Upvotes: 2