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"/>