我在许多地图示例中遇到过这样的代码:
<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=".MainActivity" >
<fragment
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.SupportMapFragment" />
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
然而,对于他们所有人来说,我得到了错误
说明资源路径位置类型为标记片段找到意外的名称空间前缀"xmlns"activity_msmap.xml/example/res/layout line 8 Android Lint问题
在线
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
Run Code Online (Sandbox Code Playgroud)
那么......这里发生了什么?我在各地的例子中看到它,但它导致我的Eclipse/Android出错?另外,为什么在父元素中也定义了同样的xml命名空间?
您无法在xml布局中两次定义命名空间.只需从片段中删除它,RelativeLayout已经定义了xmlns:android命名空间.
<fragment
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.SupportMapFragment" />
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2749 次 |
| 最近记录: |