Load image from SD card using Glide

后端 未结 4 985
执念已碎
执念已碎 2020-12-06 11:27

I\'ve been trying and searching for an answer for the past 5 hours. I\'m storing image from google plus to local folder and using Glide library to load the image into imagev

相关标签:
4条回答
  • 2020-12-06 11:56

    I am using this version

    implementation 'com.github.bumptech.glide:glide:4.8.0'

    You have to pass image uri like this given below:

     Glide.with(this)
                    .load(Uri.fromFile(new File(imageStoragePath)))
                    .apply(new RequestOptions().override(100, 100))
                    .into(imageView);
    
    0 讨论(0)
  • 2020-12-06 12:00

    Just use below line:-

    Glide.with(context).load(uri).transform(new Transform()).into(view)
    

    And for getting uri use below code:-

     Uri.fromFile(new File(Yourpath));
    
    0 讨论(0)
  • 2020-12-06 12:00

    This Worked for me as long as you Add permissions.

    File file = new File(Environment.getExternalStorageDirectory()+File.separator+"xxx/xxx/"+imgName.jpg);
                            Uri imageUri = Uri.fromFile(file);
                            Glide.with(this).load(imageUri).into(tvBestSellingProductImage3);
    
    0 讨论(0)
  • 2020-12-06 12:13

    If you have original path of image than you have to converted to URI and showing image like this

        String fileName = "1.jpg";
        String completePath = Environment.getExternalStorageDirectory() + "/" + fileName;
    
        File file = new File(completePath);
        Uri imageUri = Uri.fromFile(file);
    
        Glide.with(this)
                .load(imageUri)
                        .into(imgView);
    

    Seems like you have URI than you have to put than URI only

       Glide.with(this)
                .load(Uri)
                        .into(imgView);
    
    0 讨论(0)
提交回复
热议问题