Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android : Error Snack bar not showing correctly with Map View

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.

like image 607
Mohammad Sommakia Avatar asked Feb 02 '26 13:02

Mohammad Sommakia


1 Answers

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()
like image 83
Nima Ganji Avatar answered Feb 04 '26 06:02

Nima Ganji



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!