首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >未知片段-地图Android Studio

未知片段-地图Android Studio
EN

Stack Overflow用户
提问于 2018-11-07 02:27:36
回答 2查看 2.6K关注 0票数 1

我正在做一个可访问性项目,需要使用API Map。我在Android Studio中看不到地图。出现以下错误:

代码语言:javascript
运行
复制
Unknown Fragments - The <fragment> tag allows the layout file to dynamically include different layouts at runtime. At layout editing time the specific layout to be used is not known. You can choose which layout you would like previewed while editing the layout.
- <fragment com.google.android.gms.maps.SupportMapFragment ...> (Pick Layout ...)
 Do not warn about <fragment> tags in this session.

有谁有解决方案吗?

Screenshot of the problem

感谢您的收听

EN

回答 2

Stack Overflow用户

发布于 2020-07-13 17:34:42

这里的问题是Android studio IDE不知道在布局编辑器中插入哪个片段,因为片段是在运行时插入的。

要解决此问题,请遵循以下步骤(以下步骤适用于Sceneform片段示例,但相同的原则也适用于其他片段)

  • 如果你查看布局编辑器,你应该会在右上角看到一个红色的错误警告(Android studio 4.0)。

  • 单击此选项,您将看到一条错误消息,如上所述。

  • 单击pick layout链接,您将看到布局列表。

  • 选择您正在使用的文件并单击它。

  • Android studio将在您的布局中添加一行,以告知编辑器在预览中使用此布局。

添加的行将如下所示:

代码语言:javascript
运行
复制
<fragment
   android:id="@+id/ux_fragment"
   android:name="com.google.ar.sceneform.ux.ArFragment"
   android:layout_width="match_parent"
   android:layout_height="match_parent"
   tools:layout="@layout/sceneform_ux_fragment_layout" />  //This the new line inserted
票数 2
EN

Stack Overflow用户

发布于 2018-11-08 09:21:58

enter image description here

代码语言:javascript
运行
复制
<?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" 
xmlns:tools="http://schemas.android.com/tools" android:id="@+id/map" 
android:name="com.google.android.gms.maps.SupportMapFragment" 
android:layout_width="match_parent" android:layout_height="match_parent" 
tools:context=".MapsActivity" />
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/53177851

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档