Show Image View from file path?

前端 未结 13 931
眼角桃花
眼角桃花 2020-11-22 11:18

I need to show an image by using the file name only, not from the resource id.

ImageView imgView = new ImageView(this);
imgView.setBackgroundResource(R.drawa         


        
13条回答
  •  执笔经年
    2020-11-22 11:40

    private void showImage(ImageView img, String absolutePath) {
      
        BitmapFactory.Options options = new BitmapFactory.Options();
        options.inSampleSize = 8;
        Bitmap bitmapPicture = BitmapFactory.decodeFile(absolutePath);
        img.setImageBitmap(bitmapPicture);
    
    }
    

提交回复
热议问题