Android: 地图视图中错误提示栏未正确显示

3

这是XML布局

    <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>

以下是输出结果:

此处输入图片描述

我在XML文件的根部使用了CoordinatorLayout,并使用mapbox布局来显示地图。我不知道发生了什么,请帮帮我。

1个回答

2

只需在MapView之上创建一个视图,并在其中显示snackbar :))

布局:

<?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>

活动:

val snackbar = Snackbar.make(snackbarView, "Message :))", Snackbar.LENGTH_LONG)
snackbar.show()

谢谢,这似乎是一个聪明的解决方案,但我无法测试它,因为我已经离开了我曾经工作的公司一段时间了。 - Mohammad Sommakia
不幸的是,这个解决方案对我没有起作用(同时使用协调布局和地图视图)。 - or_dvir

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接