Android Studio Google Map V2片段呈现

问题描述:

我试图在Android Studio中为Google Map V2编写测试演示。我遵循 Androidhive Google Map V2 或更好我认为我需要。

I tried to write a test demo for Google Map V2 in Android Studio. I followed every step from Androidhive Google Map V2 or better I think I need.

我使用相同的layout_main.xml

I'm using the same layout_main.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >

    <fragment
        android:id="@+id/map"
        android:name="com.google.android.gms.maps.MapFragment"
        android:layout_width="match_parent"
        android:layout_height="match_parent"/>

</RelativeLayout>

但我总是遇到相同的渲染问题:

but I'm getting always the same rendering problem:


渲染问题

A < fragment> 标签允许布局文件动态地将不同的布局包含在运行。在布局编辑时,要使用的特定布局未知。您可以在编辑布局时选择您想要预览的布局......

Rendering Problems
A <fragment> tag allows a 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...

我完全不知道有什么问题。我忘了什么吗?
我只需要在build.gradle中添加Google服务,如

I have absolutely no idea what's the problem. Did I forget something? I just need to add Google services in the build.gradle like

compile 'com.google.android.gms:play-services:4.4.52'

我从demo中复制了清单并更改了API Key 。

I copied the manifest from the demo and changed the API Key.


渲染问题

标记 < fragment> 允许布局文件在运行时动态地包含不同的布局。在布局编辑时,要使用的特定布局未知。您可以在编辑布局时选择您想要预览的布局......

Rendering Problems
A tag <fragment> allows a 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 ... /> 标签的预览,因为它不知道要放入哪种片段。您可以放心地忽略该消息 - 当您运行它时,您的实际应用程序会将该片段渲染得很好(只要您将它正确编码!)。

This is just the preview window telling you that it can't display a preview for the <Fragment.../> tag, because it doesn't know what kind of fragment you're going to put in it. You can safely ignore that message - your actual app will render the fragment fine when you run it (as long as you code it up correctly!).