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);

更多相关文章

  1. 【Android】【配置文件】gradle和manifest的使用(五):gradle引用gra
  2. android 物理键盘 关键因素
  3. android res目录下存放图片文件夹 i m h xh xxh
  4. android获取资源文件非主流方法
  5. Andorid 文件浏览器简易实现
  6. Android的读写文件及权限设置
  7. Android /system/build.prop 文件
  8. android中选择文件,部分手机找不到文件路径问题的解决

随机推荐

  1. android adb与sdcard
  2. 【Android】Gradle自动化构建工具的用法
  3. react native ——android返回键问题
  4. Material-Design
  5. Android(安卓)init进程一些容易忽视的技
  6. Android(安卓)FFmpeg系列——4 子线程播
  7. Android(安卓)BLE开发入门教程
  8. Android(安卓)Material Design-Defining
  9. 【Android学习笔记】Android中Intent的应
  10. android 自定义ViewGroup实现可记载并呈