的setContentView()与地图碎片慢 [英] setContentView() slow with map fragment

查看:172
本文介绍了的setContentView()与地图碎片慢的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我工作的一个应用程序,显示了谷歌地图(API V2)作为一个片段。当应用程序加载它显示出地图前,一个空白的屏幕为几秒钟。我已经使用日志报表看到的延迟是,但我不知道为什么它这么慢。

I am working on an app that shows a google map (api v2) as a fragment. When the app loads it shows a blank white screen for a couple of seconds before showing the map. I have used log statements see where the delays is but I don't know why it's so slow.

下面是我的onCreate:

Here is my onCreate:

@Override
protected void onCreate(Bundle savedInstanceState) {
    Log.i(TAG, "onCreate Start -------------------------------");
    super.onCreate(savedInstanceState);
    Log.i(TAG, "onCreate 1 -------------------------------");
    setContentView(R.layout.activity_main);
    Log.i(TAG, "onCreate 2 -------------------------------");
    do_async_setup();
    Log.i(TAG, "onCreate 3 -------------------------------");
    prefs = getSharedPreferences(PREFS_NAME, 0);
    prefs_editor = prefs.edit();
    Log.i(TAG, "onCreate Finish -------------------------------"); 

这里是输出。

And here is the output.

01-20 10:05:28.802: I/HeadsUp(19544): onCreate Start -------------------------------
01-20 10:05:28.802: I/HeadsUp(19544): onCreate 1 -------------------------------
01-20 10:05:30.396: I/HeadsUp(19544): onCreate 2 -------------------------------
01-20 10:05:30.396: I/HeadsUp(19544): onCreate 3 -------------------------------
01-20 10:05:30.403: I/HeadsUp(19544): onCreate Finish -------------------------------

您可以看到一个1.5秒的延迟的setContentView。这是我的布局。

You can see a 1.5 sec delay for setContentView. Here is my layout.

<RelativeLayout 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=".MainActivity" >

<fragment xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/map"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        class="com.google.android.gms.maps.SupportMapFragment"/>

</RelativeLayout>

这是简单的日子也不好过,像当加载应用程序已经冻结。我怎样才能既加快这或隐藏延迟?

It's simply looks bad, like the app has frozen when loading. How can I either speed this up or hide the delay?

感谢

推荐答案

这是使用GLSurfaceView的缺点,例如在Android上的新地图V2。该延迟由GLSurfaceView的初始化引起的。看到这里<一href="http://$c$c.google.com/p/gmaps-api-issues/issues/detail?id=4639">http://$c$c.google.com/p/gmaps-api-issues/issues/detail?id=4639从一个Google员工近门柱#5简要说明和代码片段,以帮助这个问题(略)。请明星的问题,以提高其优先级。

This is a drawback of using a GLSurfaceView such as the new maps v2 in Android. The delay is caused by the initialisation of the GLSurfaceView. See here http://code.google.com/p/gmaps-api-issues/issues/detail?id=4639 for a brief explanation near post #5 from a Googler and a snippet to help this problem (a little). Please star the issue to increase its priority.

这篇关于的setContentView()与地图碎片慢的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆