gpt4 book ai didi

安卓工作室 : xmlns:map not working

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

在做了很多研究之后,没有发现任何东西……快速提问,有人知道为什么 Android Studio 没有使用 Map 标签吗?下面的代码是 SDK 中 map 示例的一个 fragment 。已经添加了谷歌播放服务库和支持,但没有。

显示错误

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

最佳答案

将 map fragment 移动到 FrameLayout 后,我​​遇到了同样的问题(这样我就可以在 map 顶部添加一个按钮)。

我不知道我到底做了什么,因为我是 Android 应用程序和 XML 的菜鸟,但看起来我找到了解决方案:-)

我试图从一个单独的文件中包含 fragment (使用“include”指令),一旦我放置没有任何命名空间定义的裸映射 fragment ,它就向我提出了 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"

正如我所提到的 - 我是一个新手,也许我的解决方案有一些副作用,所以如果有的话请告诉我(尽管到目前为止一切似乎都工作正常......)。

这是我的工作 map 布局,顶部有一个按钮,没有错误:

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

关于安卓工作室 : xmlns:map not working,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16991927/

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