I'm creating a simple Android app with Google Maps. I've this layout:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:map="http://schemas.android.com/apk/res-auto"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/root"
android:background="@android:color/transparent">
<fragment
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:name="com.google.android.gms.maps.MapFragment"
android:id="@+id/map2"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
map:cameraBearing="112.5"
map:cameraTargetLat="45.438122"
map:cameraTargetLng="12.318221"
map:cameraTilt="30"
map:cameraZoom="18"
map:mapType="normal"
map:uiCompass="false"
map:uiRotateGestures="true"
map:uiScrollGestures="true"
map:uiTiltGestures="false"
map:uiZoomControls="true"
map:uiZoomGestures="true"
/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/imageView"
android:src="@drawable/map"
android:layout_gravity="left|top"
android:layout_alignParentLeft="false"
android:layout_alignParentTop="false"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true" />
</FrameLayout>
AndroidStudio tell me:
Unexpected namespace prefix "map" found for tag fragment
and it marks all lines with "map" prefix as errors also if the code seem ok to me. Infact deploying my app I can see that all map tags are working on my Android device.
So I'm asking if it is only a small bug of AndroidStudio.
A little curiosity: using this layout instead AndroidStudio doesn't mark any error:
<?xml version="1.0" encoding="utf-8"?>
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
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:cameraBearing="112.5"
map:cameraTargetLat="45.438122"
map:cameraTargetLng="12.318221"
map:cameraTilt="30"
map:cameraZoom="18"
map:mapType="normal"
map:uiCompass="false"
map:uiRotateGestures="true"
map:uiScrollGestures="true"
map:uiTiltGestures="false"
map:uiZoomControls="true"
map:uiZoomGestures="true"
/>
It seems like xmlns:map="http://schemas.android.com/apk/res-auto"
namespace declaration in your <FrameLayout>
element doesnt carry downwards into <fragment>
namespace. Your second example has the namespace declaration within the element that uses it ( <fragment>
) and Android Studio recognizes it immediately.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.