全部,
按照建议here我需要从我的位图中制作一个可绘制对象。但是当我尝试使用时:
Drawable d = new Drawable( my_bmp);
它表明这个构造函数已被弃用,取而代之的是:
Drawable(Bitmap bmp, int resourceId)
我还能如何使用位图制作可绘制对象?
谢谢。
最佳答案
你可以使用
Drawable d = new BitmapDrawable(getResources(), my_bmp);
A Drawable that wraps a bitmap and can be tiled, stretched, or aligned. You can create a BitmapDrawable from a file path, an input stream, through XML inflation, or from a Bitmap object.
BitmapDrawable(Resources res, Bitmap 位图)
Create drawable from a bitmap, setting initial target density based on the display metrics of the resources.
另请参阅公共(public)构造函数@
http://developer.android.com/reference/android/graphics/drawable/BitmapDrawable.html
关于android - 从位图创建可绘制对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23074946/