这是我的 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 中存在一个已知错误。提交了几个问题:
- Issue 5002: Bug: Options can't be set on MapFragments included in other layouts
- Issue 159039: Custom XML attributes doesn't work on tag in layout XMLs
- Issue 53283: Library project namespace only working on root element
最后一次更新于 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/