Android 布局xml中的嵌套名称空间

Android 布局xml中的嵌套名称空间,android,xml,google-maps,Android,Xml,Google Maps,我想把MapFragment放在RelativeLayout中。问题是我必须使用一些自定义属性,比如zOrderOnTop,它们属于不同的名称空间 如果我把fragment作为根元素,一切都很好: <fragment xmlns:android="http://schemas.android.com/apk/res/android" xmlns:map="http://schemas.android.com/apk/res-auto" class="com.myco

我想把MapFragment放在RelativeLayout中。问题是我必须使用一些自定义属性,比如zOrderOnTop,它们属于不同的名称空间

如果我把fragment作为根元素,一切都很好:

<fragment
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:map="http://schemas.android.com/apk/res-auto"
    class="com.mycompany.testproj.CustomMapFragment"
    android:id="@+id/mapView"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:clickable="true"
    android:layout_margin="40dp"
    map:zOrderOnTop="true"
    android:background="#00000000"
/>
<fragment
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:map="http://schemas.android.com/apk/res-auto"
    class="com.mycompany.testproj.CustomMapFragment"
    android:id="@+id/mapView"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:clickable="true"
    android:layout_margin="40dp"
    map:zOrderOnTop="true"
    android:background="#00000000"
/>
但当我试图将片段放入RelativeLayout时,我得到了一个错误

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


我使用inlude解决了我的问题:

map_view.xml:

map_fragment.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" >


<include layout="@layout/map_fragment"/>

</RelativeLayout>
<fragment
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:map="http://schemas.android.com/apk/res-auto"
    class="com.mycompany.testproj.CustomMapFragment"
    android:id="@+id/mapView"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:clickable="true"
    android:layout_margin="40dp"
    map:zOrderOnTop="true"
    android:background="#00000000"
/>