Search code examples
androidandroid-buttonosmdroid

Add custom location button in right bottom corner like in GoogleMaps


What is the best way to add a button to the bottom right corner in my app with the maps, and change this button in different states like in GoogleMaps? I am using OSMDroid and need add custom button, not default.

enter image description here


Solution

  • use this layout and it get you what you are looking for

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="vertical">
    
        <RelativeLayout
    
            android:layout_width="match_parent"
            android:layout_height="match_parent">
    
            <fragment
    
                android:id="@+id/map"
                android:layout_width="match_parent"
                android:layout_height="match_parent" />
    
            <ImageView
                android:id="@+id/imageViewFlagPassenger"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerInParent="true"
                android:background="@android:color/transparent"
                android:src="@drawable/marker" />
    
            <ImageView
                android:id="@+id/btn_passenger_current_location"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentBottom="true"
                android:layout_alignParentRight="true"
                android:layout_marginBottom="20dp"
                android:layout_marginRight="10dp"
                android:background="@drawable/location_icon" />
    
        </RelativeLayout>
    
    </LinearLayout>