I am using the Google Maps API in Android Studio (through the default Google Maps Activity). I enabled setMyLocationEnabled(true)
but set setMyLocationButtonEnabled
false since I wanted to add a custom Floating Action Button, which looks better to me, for moving to the current location. When a marker is clicked, the API automatically generates direction buttons at the bottom right of the maps fragment to that marker however the FAB that I've implemented covers those buttons up.
After looking at this answer I wrapped the maps fragment and floating action button in a CoordinatorLayout
, hoping that it would move the FAB up when a marker is clicked, as it does with snackbars, but it doesn't. Is there a way to activate that motion manually or at least simulate it with touch events or something similar? I tried to look for ways to move the FAB at runtime (such as this) but I was unsuccessful in finding a fitting solution for my situation.
Here is the xml for the layout for the activity, let me know if more information is needed. Thanks in advance!
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<fragment
android:id="@+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="(hidden for privacy)"/>
<android.support.design.widget.FloatingActionButton
android:id="@+id/find_my_location"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_margin="@dimen/fab_margin"
android:src="@drawable/ic_my_location_gray"
app:backgroundTint="@color/white"/>
</android.support.design.widget.CoordinatorLayout>