哪种方法更有效创建从资源中的Drawable生成Bitmap?
Bitmap myBitmap = BitmapFactory.decodeResource(context.getResources(),
R.drawable.icon_resource);
Vs
Drawable myDrawable = getResources().getDrawable(R.drawable.icon_resource);
Bitmap myBitmap = ((BitmapDrawable) myDrawable).getBitmap();
自API 22以上版本,上述方法已被弃用,请使用以下方法
Drawable myDrawable = ContextCompat.getDrawable(context, R.drawable.icon_resource)