Android的ImageView的setImageBitmap [英] Android ImageView setImageBitmap

查看:199
本文介绍了Android的ImageView的setImageBitmap的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想,以更有效地使用内存更好地了解如何Android处理图像。我存储在位图图像,我使用 ImageView.setImageBitmap()来显示它。现在的问题是 - 将它使用位图我已经通过它在未来,或者它做它的拷贝和位图我创建不调用 setImageBitmap

Asuming它要保持参照位图我通过了,它怎么会表现得当位图是通过 BitmapFactory 创建使用 inPurgeable 选项?请问的ImageView prevent的位图被暂时从内存中清除?是不是要发生的事,只有当的ImageView View.VISIBLE 状态,或者还当查看。 GONE View.INVISIBLE ?或者,也许只有在的ImageView 是在屏幕上可见?

还有一件事 - 通过Android源$ C ​​$ C看着显示,EN codeD字节的数据始终被复制到内存中( inInputShareable 当前忽略)。它是对16 / 24MB内存限制Android的Java应用程序算的?

感谢


解决方案

看看这篇文章:的 http://developer.android.com/training/displaying-bitmaps/index.html

有一些有益的启示,可以帮助你了解Android的内存管理好

I'm trying to better understand how Android handle images in order to use memory more efficiently. I have an image stored in the Bitmap and I'm using ImageView.setImageBitmap() to display it. Now the question is - will it use the Bitmap I've passed it in the future, or it's making a copy of it and the Bitmap I've created isn't used anymore after the call to setImageBitmap?

Asuming it's gonna keep reference to the Bitmap I've passed, how is it gonna behave when Bitmap was created via BitmapFactory using inPurgeable option? Will ImageView prevent the Bitmap from being temporarily purged from the memory? Is it gonna happen only when ImageView has View.VISIBLE state, or also when View.GONE and View.INVISIBLE? Or maybe only while ImageView is visible on the screen?

And one more thing - looking through Android source code reveals that encoded byte data is always copied into memory (inInputShareable is currently ignored). Is it counted towards the 16/24MB memory limit for android Java application?

Thanks

解决方案

Take a look at this article : http://developer.android.com/training/displaying-bitmaps/index.html

There's some useful lessons that helps you to understand android's memory management better

这篇关于Android的ImageView的setImageBitmap的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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