这是我的 XML 文件的全部内容。重要的部分是最后的地图片段,它给了我这个错误:“标签片段发现意外的命名空间前缀”它似乎不会影响代码,但我很好奇是否有人知道发生了什么。我看过帖子说这是 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 中有一个已知的错误。有几个问题已提交:
- 问题 5002:Bug:无法在其他布局中包含的 MapFragments 上设置选项
- 问题 159039:自定义 XML 属性不适用于布局 XML 中的标记
- 问题 53283:库项目命名空间仅适用于根元素
最后一次更新于 2016 年 7 月 14 日指出“请在较新版本的 Android Studio(2.2 或更高版本)上重试。如果问题仍然出现,请提交新的错误。”
作为解决方法,您可以将此属性添加到片段以忽略错误(我已经测试过它并且map:
属性按预期工作):
tools:ignore="MissingPrefix"
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)