导致帧背景图像被跳过 [英] background images causing frames to be skipped

查看:150
本文介绍了导致帧背景图像被跳过的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个非常简单的应用程序只是一个的TextView 按钮 A 的RelativeLayout (与背景图像):

I have a very simple app with just a TextView and a Button inside of a RelativeLayout (with a background image):

<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" android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".MainActivity"
    android:background="@drawable/background_image" >

    <!-- text in top left of background -->
    <TextView android:text="App" android:layout_width="wrap_content"
        android:layout_height="wrap_content" />

    <!-- primary button that outputs audio -->
    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Text
        android:layout_centerVertical="true"
        android:layout_centerHorizontal="true"
        android:onClick="trueButtonClick" />

</RelativeLayout>

的onClick 事件只是扮演一些音频:

The onClick event just plays some audio:

public void trueButtonClick(View v) {
    //create media player
    MediaPlayer mp = MediaPlayer.create(this, R.raw.audio_test);
    //make noise
    mp.start();
}

在logcat中,我得到这些消息:

In logcat, I get these messages:

03-02 23:41:40.063    1910-1910/com.example.mohammad.trueapp E/MediaPlayer﹕ Should have subtitle controller already set 
03-02 23:41:40.063    1910-1910/com.example.mohammad.trueapp I/Choreographer﹕ Skipped 210 frames!  The application may be doing too much work on its main thread.
03-02 23:41:43.961    1910-1910/com.example.mohammad.trueapp I/Choreographer﹕ Skipped 232 frames!  The application may be doing too much work on its main thread. 
03-02 23:45:05.506    1910-1910/com.example.mohammad.trueapp I/Choreographer﹕ Skipped 115 frames!  The application may be doing too much work on its main thread. 
03-02 23:45:07.279    1910-1910/com.example.mohammad.trueapp E/MediaPlayer﹕ Should have subtitle controller already set 
03-02 23:45:07.323    1910-1910/com.example.mohammad.trueapp I/Choreographer﹕ Skipped 108 frames!  The application may be doing too much work on its main thread. 
03-02 23:45:10.490    1910-1910/com.example.mohammad.trueapp E/MediaPlayer﹕ Should have subtitle controller already set

当我删除了背景图片 @绘制/ background_image ,应用程序加速。然而,添加的背景图像后,该应用程序是如此之慢,它似乎从用户的角度来看破碎。背景图像大小为1040x851。有没有一种方法,我可以加快这为prevent激烈的滞后?

When I remove the background image @drawable/background_image, the application speeds up. However, after adding the background image, the application is so slow that it seems broken from the user's perspective. The background image size is 1040x851. Is there a way I can speed this up to prevent the drastic lag?

推荐答案

这是发生,因为您是要装入大尺寸图片。尝试优化它的分辨率。

This is happening because you are loading a big size image. Try to optimize the resolution of it.

1px的= 4字节的内存

1px = 4 byte memory

通过这个你可以来了解你的应用程序是多少取内存

Through this you can come to know how much your app is taking the memory

这篇关于导致帧背景图像被跳过的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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