setImageResource VS setDrawable [英] setImageResource Vs setDrawable

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

问题描述

当谈到Android的开发和性能,如果你有ImageView的那么哪一个会更快,更好(是有区别反正!):setImageResource和setDrawable Iknow 1取ID和另一个需要可拉伸。但我会得到从ID的drwable反正。 哪一个你认为是更好的?

When it comes android development and performance, if you have imageview then which one would be faster or better (is there a difference anyways!): setImageResource and setDrawable Iknow one takes ID and the other one takes drawable. But I will be getting the drwable from ID anyways. Which one do you think is better?

或者我应该避免使用ImageView的产品总数和使用负载/绘制位图? 太多的选择是混乱 感谢您的意见

Or should I avoid using imageview alltogether and use load/draw bitmap? too many selections is confusing Thanks for the comments

推荐答案

他们是不同的。从<一个href="http://developer.android.com/reference/android/widget/ImageView.html#setImageResource%28int%29"相对=nofollow> Android的文件的。

setImageResource: 这确实位图读取和解码 UI线程,这可能导致延迟打嗝上。

setImageResource: This does Bitmap reading and decoding on the UI thread, which can cause a latency hiccup.

如果这是一个问题,请考虑使用setImageDrawable(android.graphics.drawable.Drawable)或setImageBitmap(android.graphics.Bitmap)和BitmapFactory代替。

If that's a concern, consider using setImageDrawable(android.graphics.drawable.Drawable) or setImageBitmap(android.graphics.Bitmap) and BitmapFactory instead.

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

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