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

获取资源文件 r.drawable中的图片转换为drawable、bitmap的更多相关文章

  1. android 获取资源文件 r.drawable中的图片转换为drawable、bitmap

    1.R-Drawable Resources resources = mContext.getResources(); Drawable drawable = resources.getDrawabl ...

  2. java基础知识3--如何获取资源文件(Java中获取资源文件的url)

    java开发中,常见的resource文件有:.xml,.properties,.txt文件等,后台开发中经常用到读取资源文件,处理业务逻辑,然后返回结果. 获取资源文件的方法说明getResourc ...

  3. Java中获取资源文件的方法总结

    这里总结3中方法获取资源文件的 ServletContext Class ClassLoader 文件的位置 1. ServletContext public void doGet(HttpServl ...

  4. wpf 前台获取资源文件路径问题

    1 <ImageBrush ImageSource="YT.CM.CommonUI;component/Resource/FloadwindowImage/middle.png&quo ...

  5. 替换res\drawable中的图片

    现象 在android开发中,经常会需要替换res\drawable中的图片,打开res\layout下的文件预览布局页面发现图片已经被替换,但在模拟器或者真实机器上运行时发现该图片并没有被替换,还是 ...

  6. 【Spring】获取资源文件+从File+从InputStream对象获取正文数据

    1.获取资源文件或者获取文本文件等,可以通过Spring的Resource的方式获取 2.仅有File对象即可获取正文数据 3.仅有InputStream即可获取正文数据 package com.sx ...

  7. JavaWeb基础: 获取资源文件

    Web工程在编译构建完毕以后,需要部署到Tomcat上运行,资源的硬盘路径也会随着改变.要想对资源文件进行读写操作需要获取其硬盘地址,在Web工程中通常通过ServletContext/ClassLo ...

  8. 关于获取资源文件,Class.getResource和ClassLoader.getResource的区别

    原文同步发表至个人博客[夜月归途] 原文链接:http://www.guitu18.com/se/java/2019-02-22/29.html 作者:夜月归途 出处:http://www.guitu ...

  9. 【spring Boot】spring boot获取资源文件的三种方式【两种情况下】

    首先声明一点,springboot获取资源文件,需要看是 1>从spring boot默认的application.properties资源文件中获取 2>还是从自定义的资源文件中获取 带 ...

随机推荐

  1. 【Python】使用geopy由地址找经纬度等信息

    代码: from geopy.geocoders import Nominatim geolocator = Nominatim() location = geolocator.geocode(&qu ...

  2. Creating objects on stack or heap

    class Player {  private: int health;  int strength;  int agility; public: void move(); void attackEn ...

  3. IEngineEditor接口的0x80004003错误

    在定制ArcEngine数据编辑程序时,经常使用IEngineEditor 接口来完成开始.保存和停止编辑.但我遇到了一个问题,测试纠结了两天终于解决,我十分佩服自己.嘻嘻. 错误描述 使用IEngi ...

  4. Windows下搭建elasticsearch集群案例

    https://blog.csdn.net/u014236259/article/details/64129918

  5. Your account already has a signing certificate for this machine but it is not present in your keycha

    转载自:https://blog.csdn.net/csdn2314/article/details/73124117 Your account already has a signing certi ...

  6. common.js 2017

    String.IsNullOrEmpty = function (v) { return !(typeof (v) === "string" && v.length ...

  7. PHP http_build_query()方法

    http_build_query (PHP 5) http_build_query -- 生成 url-encoded 之后的请求字符串描述 string http_build_query ( arr ...

  8. JAVA设计模式——第 2 章 代理模式【Proxy Pattern】(转)

    什么是代理模式呢?我很忙,忙的没空理你,那你要找我呢就先找我的代理人吧,那代理人总要知道被代理人能做哪些事情不能做哪些事情吧,那就是两个人具备同一个接口,代理人虽然不能干活,但是被代理的人能干活呀. ...

  9. javascript数字转大写

    万亿级别,这个还有bug的 function money2Uppercase(num) { var m = parseInt(num); var ml = (m.toString()).split(' ...

  10. Ajax的优缺点及工作原理?

    定义和用法: AJAX = Asynchronous JavaScript and XML(异步的 JavaScript 和 XML).Ajax 是一种用于创建快速动态网页的技术.Ajax 是一种在无 ...