带有背景图片的慢速应用 [英] Slow App with Background image

查看:139
本文介绍了带有背景图片的慢速应用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为Android制作一个小游戏.当它在白色背景上工作时,它工作正常,但是当我要放置背景图像时,它变得越来越慢.首先,我尝试将其添加为布局背景图像,但速度非常慢,动画是逐帧进行的.然后我决定在画布上将背景图像绘制为位图,结果比上一个要快一点,但与白色背景相比仍然没有任何效果.

I am making a small game for android. It is working smoothly when its working on a white background but when i want to put a background image, its becoming slower and slower. First i tried to add it as a layout background image but it was very slow, the animations were happening frame by frame. And then i decided to draw the background image as a Bitmap on canvas, the result was a little faster than the previous one but still its nothing comparing to the white background.

我尝试过多次缩放图像,我以更高的分辨率,更低的分辨率进行了缩放,但是结果没有改变,但仍然很慢.

I tried to scale the image many times, i did it with higher resolution, lower resolution, but the result didnt change, its still slower.

所以我想问,有没有一种方法可以将背景图像添加到android应用程序而又不损失应用程序的平滑度和速度?

So i wanted to ask, is there a way to add a background image to an android app without losing the smoothness and speed of the application?

谢谢

P.S:我正在索尼平板电脑S上尝试我的应用程序

P.S: I am trying my application on Sony Tablet S

推荐答案

很晚了,但是如果其他人也遇到了同样的问题; 在绘制时,它可能会尝试重新调整大小,您可以使用no-dpi(drawable-nodpi/drawable-sw600dp-nodpi)文件夹跳过调整大小,这需要大量的CPU和时间.

its pretty late but if someone else have the same problem ; on the draw it may try to resize again, you can use no-dpi (drawable-nodpi / drawable-sw600dp-nodpi) folder to skip resizing which requires so much cpu and time.

还有其他原因可能会导致这种情况,我认为您忘记了回收旧的位图.

also something else may cause this , which i assume you forget to recycle old your bitmaps.

这篇关于带有背景图片的慢速应用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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