2

enter image description here

I've tried several different ways but the imageview still show only a gray square. I'm testing on API 17.

Below are the options I've tried unsuccessfully:

  • Configured the ImageView in XML to:

  • fixed width and height; width and height to wrap_content; width to match_parent and height to wrap_content

  • android: scaleType to "fitXY" and "centerCrop"
  • android: adjustViewBounds to true | false;

Image loading methods tried:

binding.captcha.setImageBitmap (BitmapFactory.decodeFile (imgFile2.getAbsolutePath ()));

Also tried this answer https://stackoverflow.com/a/35830800/1764042

Tried Glide:

    Glide.with(this)
    .load (Uri.fromFile (imgFile2))
    .skipMemoryCache (true)
    .diskCacheStrategy (DiskCacheStrategy.NONE)
    .override (150, 150)
    .centerCrop ()
    .into (binding.captcha);

The option below is the only that displays the image (in background), however I would like to know what could be happening to prevent me from displaying the image using default methods ...

    Drawable drawableImage = new BitmapDrawable(BitmapFactory.decodeFile(imgFile2.getAbsolutePath()));
    binding.captcha.setBackgroundDrawable(drawableImage);
  • Notes:
  • imgFile2 is not empty, it is loaded from SD Card.
  • imgFile2 is showing if I use it as background so the problem is not with the file.
  • The problem is not simply solved with a lib, I'm already trying Glide... But if you Know what I need to do to make it work with glide...
  • The imageView is inside a fragment, if it matters.

Current xml:

        <ImageView
            android:layout_width="150dp"
            android:layout_height="150dp"
            android:layout_centerHorizontal="true"
            android:id="@+id/captcha"/>
Johny
  • 501
  • 5
  • 16

1 Answers1

4

For those who are still facing this issue, for me this is caused because of android:tint property of ImageView to which I was setting image into using Glide.

I was displaying a dummy placeholder image with android:tint as a shade of grey while the actual image loads from url. And that tint was causing the problem.

So try removing the android:tint property alltogether or set the tint to null programmatically after loading the image using imageView.setImageTintList(null)

Hope it helps

Susheel Karam
  • 837
  • 7
  • 16