I am trying to add an overlay to my google map, which is fixed in the center of the screen so that users can use it to accurately select a location.
Currently, the code below draws a map with a centered image of a crosshair, but since the button is below the map, the center of the map changes and the crosshair no longer represents the center point of the map that was moved up the buttonโs height.
I looked at Android - showing a crosshair in the center of my Google Map , but it seems to be suitable only for v1 :(
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent"> <fragment xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/locationpicker_map" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_above="@+id/locationpicker_add_venue" android:clickable="true" android:layout_weight="1" class="com.google.android.gms.maps.SupportMapFragment"/> <ImageView android:id="@+id/imageView1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/crosshairs" android:layout_gravity="center_vertical" android:layout_centerInParent="true"/> <Button android:id="@+id/locationpicker_add_venue" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text = "Add new venue here" android:layout_alignParentBottom="true"/> </RelativeLayout>
source share