首页 > IT职业 > IT图书 > android 下的 assets目录
assets文件在打包后会原封不动的保存在apk包中,不会被编译成二进制。
assets可以建立多级目录
assets文件夹下的文件不会被映射到R.java中,访问的时候需要AssetManager类。
下面是一个封装好的获取Bitmap资源的工具类:
public static Bitmap getBitmapFromAsset(Context context, String filePath) {
AssetManager assetManager = context.getAssets();
InputStream istr;
Bitmap bitmap = null;
try {
istr = assetManager.open(filePath);
bitmap = BitmapFactory.decodeStream(istr);
} catch (IOException e) {
// handle exception
}
return bitmap;
}
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/813/viewspace-2798946/ ,如需转载,请注明出处,否则将追究法律责任。