gpt4 book ai didi

android - 如何将 GoogleMap fragment 包装成 LinearLayout?

转载 作者:塔克拉玛干 更新时间:2023-11-02 22:21:49 24 4
gpt4 key购买 nike

我试过这个:

<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>

但是我有两个错误:

  1. <fragment xmlns:map="http://schemas.android.com/apk/res-auto" :

Unexpected namespace prefix "xmlns" found for tag fragment

2。 map:mapType="normal" :

Unexpected namespace prefix "map" found for tag fragment

我做错了什么,为了在我的应用中集成除 Google 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

如果属性不起作用,我可能只是以编程方式设置值。

关于android - 如何将 GoogleMap fragment 包装成 LinearLayout?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15706438/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com