-
自定义字符串标签
在values下面创建文件,values/speed_strings.xml<?xml version="1.0" encoding="utf-8"?>
<resources>
<item name="txt_1" type="speed_string">http://speed_string.com</item>
</resources>
代码中使用Log.d("", getResources().getString(R.urls.myUrl));
-
读取assets文件下图片
private Bitmap getImageFromAssetsFile(String fileName) { Bitmap image = null; AssetManager am = getResources().getAssets(); try { InputStream is = am.open(fileName); image = BitmapFactory.decodeStream(is); is.close(); } catch (Exception e) { e.printStackTrace(); } return image; } //图片过大时可能会内存溢出,使用BitmapFactory.Options BitmapFactory.Options options = new BitmapFactory.Options(); options.inJustDecodeBounds = true; //读取图片的轮廓 Bitmap bmp = BitmapFactory.decodeFile(path, options);/* 这里返回的bmp是null */ options.inSampleSize = options.outWidth / 200; //图片长宽方向缩小倍数 Bitmap bmp = BitmapFactory.decodeFile(path, options); options.inDither=false; //不进行图片抖动处理 options.inPreferredConfig=null; //设置让解码器以最佳方式解码 //下面两个字段需要组合使用 options.inPurgeable = true; options.inInputShareable = true;
游戏SDK开发_总结
最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
推荐阅读更多精彩内容
- View 自定义View中在onDraw()方法中可以设置padding吗?答案是不能,设置padding后,Vi...
- 一直以来Bitmap都是开发中很棘手的问题,这个问题就是传说中的OOM(java.lang.OutofMemory...