- 定义Bitmap对象
private Bitmap mBitmap;
- 对Bitmap对象进行实例化,解析图片资源,并转换成位图形式
Resources res=getResources(); mBitmap=BitmapFactory.decodeResource(res, R.drawable.toBitmap);//实例化Bitmap对象
- 实例化Drawable对象
Drawable drawable = getResources().getDrawable(R.drawable.kk_hero);
img.setImageDrawable(drawable);//set Drawabel
- 定义并实例化ImageView对象,同时为该控件设置位图资源
ImageView img=(ImageView)v.findViewById(R.id.img); img.setImageBitmap(mBitmap);
ImageView,Bitmap,Drawable
最新推荐文章于 2024-08-12 04:02:36 发布