android - Bitmap、BitmapDrawable 和 Drawable 有什么区别?

标签 android performance android-drawable android-bitmap

我看到了这个答案:What is the difference between Bitmap and Drawable in Android?

谁能给出一个实际的解释?什么时候使用?优势劣势?

最佳答案

Bitmap 只是一个原样的图像。理想情况下,它将用于使用 CanvasSurfaceView 或类似的东西在屏幕上绘制像素。

Drawable 是一个描述可以在屏幕上绘制的东西的类。

BitmapDrawableDrawable 的子类。这意味着它是一个想要绘制图像的 Drawable

通常 android View 使用 Drawable 对象,所以 Drawable 的任何子类都是可以接受的,这意味着如果你想使用 Bitmap (原始像素)在 View 上,您需要创建一个 BitmapDrawable 并将其传递给它。

关于android - Bitmap、BitmapDrawable 和 Drawable 有什么区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33929278/

相关文章:

安卓 NDK : Including boost c++ library

java - 如何在 Java(Android) 上迭代我的 RadioButton 以查找字符串

android - 如何在 Picasso 中为 resize() 值选择值

c - openmp 比一个线程慢,无法弄清楚

java - android studio 中带有 setImageDrawable 方法的 NullPointerException

android - 在图像上绘制而不是在 android 中的 ImageView 上绘制

java - 构造函数中的动态方法定义

Android 数据库列表适配器 : multiple columns, 对齐?

javascript - Fabric.js 中的灰度很慢

c# - IIS 工作进程和工作线程