Android:错误小吃栏无法在地图视图中正确显示 [英] Android : Error Snack bar not showing correctly with Map View

查看:136
本文介绍了Android:错误小吃栏无法在地图视图中正确显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

这是输出:

我正在使用 CoordinatorLayout 作为我的 xml文件 mapbox 布局的根目录来显示地图. 我不知道发生了什么事,请帮助我.

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.

推荐答案

只需在MapView顶部创建一个视图并在其中显示小吃栏:))

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

布局:

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

这篇关于Android:错误小吃栏无法在地图视图中正确显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆