我试过了:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<fragment xmlns:map="http://schemas.android.com/apk/res-auto"
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:name="com.google.android.gms.maps.SupportMapFragment"
map:mapType="normal"
/>
</LinearLayout>
但是我得到了2个错误:
-
<fragment xmlns:map="http://schemas.android.com/apk/res-auto"
:
在标签片段中找到意外的命名空间前缀"xmlns"
2。map:mapType="normal"
:
在标签片段中找到意外的命名空间前缀"map"
我做错了什么,以及它应该如何看起来像为了在我的应用程序中集成更多的对象除了谷歌地图…
非常感谢!
编辑! !
我试过这个,它工作!
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:map="http://schemas.android.com/apk/res-auto"
map:mapType="normal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<fragment
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:name="com.google.android.gms.maps.SupportMapFragment"
/>
</LinearLayout>
我不明白为什么…也不明白map:mapType="normal"
和xmlns:map="http://schemas.android.com/apk/res-auto"
是什么意思…? ?
你试过了吗:
<LinearLayout
xmlns:map="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<fragment
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.SupportMapFragment"
/>
</LinearLayout>
从http://developer.android.com/reference/com/google/android/gms/maps/SupportMapFragment.html可以看出这两个属性是不需要的。
我也用class
代替android:name
。
要使用map
属性,您需要添加名称空间(我认为您可以将其添加到LinearLayout
,更多信息请访问https://developers.google.com/maps/documentation/android/map#using_xml_attributes。
如果属性不工作,我可能只是通过编程设置值。
据我所知,这是一个已知的bug,如果你用布局包装你的地图,你不能使用map
前缀属性,你必须在你的代码中自定义地图。