为标记片段找到意外的命名空间前缀"xmlns" 为标记片段找到意外"map"命名空间前缀



为什么在标签片段中发现意想不到的命名空间前缀"xmlns"
意外的命名空间前缀"地图"发现标记片段?

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".Main">
    <fragment xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:map="http://schemas.android.com/apk/res-auto"
        android:id="@+id/map"
        android:name="com.google.android.gms.maps.MapFragment"
        map:mapType="satellite"/>
</RelativeLayout>

为什么在标签片段中发现了意外的命名空间前缀"xmlns"

xmlns:android="http://schemas.android.com/apk/res/android"<fragment>元素移除,并考虑将xmlns:map="http://schemas.android.com/apk/res-auto"<fragment>元素移至根元素

例如:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:map="http://schemas.android.com/apk/res-auto"
    android:id="@+id/foo"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    <fragment
        android:id="@+id/map"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        class="com.google.android.gms.maps.SupportMapFragment"
        map:mapType="satellite"/>
</RelativeLayout>

显然这只是一个误导的Lint检查错误。当您在Eclipse的Problem视图中右键单击错误行,选择Quick fix选项并选择例如Ignore Check for project时,您可以删除它。

错误消失,项目构建,应用程序运行良好。

试试这个

 <fragment
        android:id="@+id/map"
        android:name="com.google.android.gms.maps.SupportMapFragment"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_alignParentLeft="true"
        android:layout_alignParentRight="true"
        android:layout_alignParentTop="true"

最新更新