android - 意外的命名空间 "map"- Android Google Maps API

标签 android google-maps android-layout android-fragments

这是我的 XML 文件的完整内容。重要的部分是最后的 map fragment 给我这个错误:“为标签 fragment 找到意外的命名空间前缀”它似乎不会影响代码但我很好奇是否有人知道是什么向上。我看到帖子说这是 Lint 问题或 Eclipse 问题,但我使用的是最新版本的 Android Studio。

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              android:layout_width="fill_parent"
              android:layout_height="fill_parent"
              xmlns:map="http://schemas.android.com/apk/res-auto"
              android:background="#FFFFFF"
              android:orientation="vertical">

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:orientation="horizontal">

        <Button
            android:id="@+id/button_lakeside_webview"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Lakeside"/>

        <Button
            android:id="@+id/button_spinner_webview"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Spinner"/>

    </LinearLayout>

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content">

        <View
            android:id="@+id/colored_bar"
            android:layout_width="48dp"
            android:layout_height="3dp"
            android:background="" />

    </LinearLayout>

    <!-- Unsure why it complains about the map namespace, the below code is recommended by Google -->

    <fragment xmlns:android="http://schemas.android.com/apk/res/android"
              xmlns:map="http://schemas.android.com/apk/res-auto"
              android:name="com.google.android.gms.maps.SupportMapFragment"
              android:id="@+id/map"
              android:layout_width="match_parent"
              android:layout_height="match_parent"
              map:cameraBearing="0"
              map:cameraTilt="30"
              map:cameraZoom="16"
              map:mapType="normal"
              map:uiCompass="false"
              map:uiRotateGestures="false"
              map:uiScrollGestures="false"
              map:uiTiltGestures="false"
              map:uiZoomControls="false"
              map:uiZoomGestures="false"/>

</LinearLayout>

最佳答案

正如您所说,Android Lint 中存在一个已知错误。提交了几个问题:

最后一次更新于 2016 年 7 月 14 日,声明“请在较新版本的 Android Studio(2.2 或更高版本)上重试。如果问题仍然存在,请提交新错误。”

作为解决方法,您可以将此属性添加到 fragment 以忽略错误(我已经对其进行了测试并且 map:properties 按预期工作):

tools:ignore="MissingPrefix"

关于android - 意外的命名空间 "map"- Android Google Maps API,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38465977/

相关文章:

android - 如何增加MPAndroidChart饼图中百分比值的大小?

android - Mapbox IllegalStateException : Calling getSourceAs when a newer style is loading/has loaded

android - 用 KitKat 的灰色色调覆盖 Android 的蓝色色调的最简单方法是什么?

android - Android LayoutInflater类的inflate方法中第二个参数怎么用

java - 二进制 XML 文件行 #2 : Error inflating class

javascript - Backbone 收集数据谷歌地图

javascript - Google map 、标记信息窗口不会显示?

google-maps - 我可以将 google map/api 与 openlayers 集成吗?

Android EditText 没有聚焦

java - 从 ListView 中选择一个项目