Layout used in the Activity (for GoogleMap)
<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/cl_map"
android:layout_width="match_parent"
android:layout_height="match_parent">
<fragment
android:id="@+id/fr_map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ui.activity.MapActivity" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>
In the very same Activity, this was how a snack bar was created, when a marker was clicked.
override fun onMarkerClick(p0: Marker?): Boolean {
Snackbar.make(findViewById(R.id.cl_map), "Hello World", Snackbar.LENGTH_INDEFINITE).show()
// finding android.R.id.content does not work either
// Snackbar.make(findViewById(android.R.id.content), "Hello World", Snackbar.LENGTH_INDEFINITE).show()
return false
}
Here are the screenshots and a few symptoms:
for the initial click of a marker:
Please pay attention to the black slim line. That was the snack bar.
But if I clicked anywhere in the map body, instead of a marker, the snack bar became normal.
What's more, if I set the uiSettings.isMapToolbarEnabled false, the default toolbar was hidden, but the snack bar never showed up. I could not even saw the black slim line at all, no matter what click I have.
this.googleMap?.uiSettings?.isMapToolbarEnabled = false
One similar question here. The phone I took screenshots from was a Nexus 5. Native Android 6.0.1, the latest OS a Nexus 5 can support.