[英]AndroidManifest.xml xmlns isn't working in Android Studio
[英]Android Studio: xmlns:map not working
經過大量研究,但沒有發現任何東西...快速提問,是否有人知道Android Studio為什么不使用Map標簽? 下面的代碼是SDK中地圖示例的一部分。 已經添加了谷歌播放服務庫和支持,但什么也沒有。
顯示錯誤
Unexpected namespace prefix "map" found for tag fragment.
在此先多謝!
<fragment
xmlns:map="http://schemas.android.com/apk/res-auto"
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.SupportMapFragment"
map:cameraZoom="10" />
將地圖片段移入FrameLayout后,我遇到了同樣的問題(因此我可以在地圖頂部添加一個按鈕)。
我不知道我實際上做了什么,因為我是Android應用程序和XML的菜鳥,但是看來我找到了解決方案:-)
我試圖使技巧包括一個來自單獨文件的片段(使用'include'指令),並且一旦我將沒有任何名稱空間定義的裸露地圖片段放入其中,便向我提出了2個選擇:xmlns:map =“ http://schemas.android .com / apk / res-auto“ xmlns:map =” http://schemas.android.com/tools“我意識到也許第二個版本可以在原始文件中使用(盡管Android Studio在原始文件中並未提出建議) ,但只有第一個)。
結論:只需更改此行:xmlns:map =“ http://schemas.android.com/apk/res-auto”並輸入以下內容:xmlns:map =“ http://schemas.android.com/tools”
正如我所提到的-我是菜鳥,也許我的解決方案有某些副作用,所以請讓我知道是否可以(盡管到目前為止一切工作都很好...)。
那是我的工作地圖布局,頂部有一個按鈕,沒有錯誤:
<?xml version="1.0" encoding="utf-8"?> <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" xmlns:map="http://schemas.android.com/tools" tools:context="com.maverickrider.myapp.inviteActivity.MapsActivity" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@color/purpura_E51B4A"> <fragment android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/map" android:name="com.google.android.gms.maps.MapFragment" map:cameraTargetLat="51.513259" map:cameraTargetLng="-0.129147" map:cameraTilt="30" map:cameraZoom="13" /> <Button android:id="@+id/startActivityButton" android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="center_horizontal|center_vertical" android:onClick="cokolwiek" android:text="Baton z dupy" android:layout_alignParentBottom="true" /> </FrameLayout >
我也有這個問題。 我做了Project / Clean,錯誤消失了,現在可以正常工作了。 假設在使用該名稱空間的上方正確定義了該名稱空間。
我正在運行0.5.8,並且XML查看器使用map突出顯示了attrs:-但是該應用程序構建良好。 YMMMV。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.