3

this is xml layout

    <android.support.design.widget.CoordinatorLayout
        android:id="@+id/map_location_picker_main_content"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <com.mapbox.mapboxsdk.maps.MapView
            android:id="@+id/map_view"
            android:layout_width="match_parent"
            android:layout_height="match_parent" />
    </android.support.design.widget.CoordinatorLayout>

and this is the output :

enter image description here

I am using a CoordinatorLayout as a root of my xml file and mapbox layout for showing the map. I don't know what is happening please help me.

jins joseph
  • 271
  • 1
  • 11
Mohammad Sommakia
  • 1,773
  • 3
  • 15
  • 48

1 Answers1

2

Just create a view on top of MapView and show snackbar within it :))

Layout:

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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"
    xmlns:mapbox="http://schemas.android.com/apk/res-auto"
    tools:context=".MainActivity">

    <com.mapbox.mapboxsdk.maps.MapView
        android:id="@+id/mapView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"/>

    <View
        android:id="@+id/snackbarView"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

</androidx.constraintlayout.widget.ConstraintLayout>

Activity:

val snackbar = Snackbar.make(snackbarView, "Message :))", Snackbar.LENGTH_LONG)
snackbar.show()
Nima Ganji
  • 561
  • 8
  • 17