android获取资源文件R.drawable中的图片的相关方法
16lz
2021-01-23
1.
// 获取资源文件的关键!
Resources resources = mContext.getResources();
Drawable drawable = resources.getDrawable(R.drawable.a);
imageview.setBackground(drawable);
2、
Resources r = this.getContext().getResources();
Inputstream is = r.openRawResource(R.drawable.my_background_image);
BitmapDrawable bmpDraw = new BitmapDrawable(is);
Bitmap bmp = bmpDraw.getBitmap();
3、
Bitmap bmp=BitmapFactory.decodeResource(r, R.drawable.icon);
Bitmap newb = Bitmap.createBitmap( 300, 300, Config.ARGB_8888 );
4、
InputStream is = getResources().openRawResource(R.drawable.icon);
Bitmap mBitmap = BitmapFactory.decodeStream(is);
更多相关文章
- 【Android】【配置文件】gradle和manifest的使用(五):gradle引用gra
- android 物理键盘 关键因素
- android res目录下存放图片文件夹 i m h xh xxh
- android获取资源文件非主流方法
- Andorid 文件浏览器简易实现
- Android的读写文件及权限设置
- Android /system/build.prop 文件
- android中选择文件,部分手机找不到文件路径问题的解决