2016-04-24 73 views
1

我现在正在尝试使用android studio制作谷歌地图应用程序。Android Studio渲染片段问题

现在,一切都很好,除了一两件事,当我去“设计”选项卡,在XML文件中我有这个Redering消息:

呈现问题的标签允许布局文件到 在运行时动态包含不同的布局。在布局编辑 时间,要使用的特定布局未知。你可以选择 布局你想预览在编辑布局...

和主要的问题是,我不能在我的布局使用任何GUI组件,我搜索我的问题了,我明白有了这个错误,人们看不到他们的地图,但他们可以把文本框,小部件,布局等。 但对于我来说,我的预览完全冻结,我不能做任何修改。

Picture of my android studio page.

回答

0

只要使用这种设计的片段<fragment>部分。这解决了我的问题。同时,请参阅this链接

<fragment 
    android:id = "@+id/ma" 
    android:name = "com.google.android.gms.maps.SupportMapFragment" 
    android:layout_width = "match_parent" 
    android:layout_height = "match_parent" 
    tools:context = "com.example.demomaps.MapsActivity" 
    /> 
0

正如你可以与你的代码中动态改变的片段,机器人工作室不知道在设计时要显示的布局。这是你错误的原因。 要具体告诉android显示哪个布局,请将tools:layout="@layout/Your_layout_name"属性添加到您的片段。 错误描述下面还有一个快捷方式链接,您已经知道。只需点击链接,android会为你添加它,你会看到布局中的片段,没有渲染错误信息。 有关详细示例:

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
tools:context="com.example.insane.fragmenttest.MainActivity"> 

<fragment 
    android:id="@+id/testFragmentID" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    class="com.example.insane.fragmenttest.WorkOutDetails" 
    tools:layout="@layout/fragment_work_out_details" /> <!-- This is the line you want to add. --> 

</LinearLayout> 
0

是的,我解决了这个easily..Simply忽略该消息并点击正在显示下面的渲染信息的线。 其实片段包含布局内部,如果它不包含它显示的警告,它必须包含你可以简单地忽略此警告下的警告,那么这个渲染问题将得到解决。