- Bitmap bitmap = Utils.getLoacalBitmapByAssets(activity, "a.png");
- if(bitmap!=null){
- rl2.setBackgroundDrawable(BitmapCache.getDrawable(activity, "a.png"));
- }
- public static Bitmap getLoacalBitmapByAssets(Context c, String url) {
- Bitmap bitmap = null;
- InputStream in = null;
- try {
- in = c.getResources().getAssets().open(url);
- bitmap = BitmapFactory.decodeStream(in);
- } catch (IOException e) {
- e.printStackTrace();
- } finally {
- try {
- in.close();
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- return bitmap;
- }
判断assets中图片是否存在
最新推荐文章于 2021-09-28 11:14:29 发布