android - Android Studio 中的 MapView 在哪里?

标签 android android-mapview

我在 Android Studio 调色板中找不到 map View 。我正在使用新的 Android Studio,它看起来很傻,但我找不到它。我查看了开发站点,但似乎 mapview 仍然存在。
有什么我想念的吗?

我还尝试将它添加到 XML 中,但它说找不到 mapview 类。

最佳答案

在 Android Studio(以及 IntelliJ)中,调色板中没有 MapView。如果您需要在布局中使用 map ,请使用以下声明:

<fragment
    android:id="@+id/map"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    class="com.google.android.gms.maps.MapFragment" />

Google Maps Android API v2 documentation

There您对如何使用 map v2 有很好的引用。

我们在 Android map v1 中使用了 MapView,但现在它已被弃用 (reference)。所以这就是Android Studio调色板中没有MapView的原因。

关于android - Android Studio 中的 MapView 在哪里?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16878376/

相关文章:

android - 没有 UI 的 Activity

java - JSONException : No value for error

java - 以当前位置为圆心在google map 上画四个圆圈

android - MapActivity 错误 : force close

android - 如何只绘制 map 上可见的标记?

java - MapView 不工作 [android]

java - 监听 Firebase Firestore 数据库中的元数据更改

Android.Views.InflateException : Binary XML file line #17: Error inflating class android. 支持.design.internal.NavigationMenuItemView

android - READ_EXTERNAL_STORAGE 不适用于 Android 10

android - MapView.preLoad() 究竟做了什么?