1

I am loading images from drawable folder into recycler. Am getting resource id using filename & calling setImageResource on image view to display the image.

I have checked am getting resource id as well but image is not displayed.

Problem is if shrinkResources is set to true some of the images from drawable folders are shown but others are not visible.

I tried after renaming the image name but result is same. If I disable the shrinking then all images are visible.

Don't want to set shrinkResources to false please suggest any other solution.

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
napster
  • 687
  • 1
  • 8
  • 18
  • Take a look here: https://stackoverflow.com/questions/41779849/android-images-are-not-displayed-after-release-build-or-if-i-instant-run-turn-of – Gaurav Mall Aug 13 '19 at 08:09
  • Already referred to that link as per the link you have to set shirkResources to false. After setting it to false its working but am looking for alternate solution as setting it to false is increasing apk size. Can we make any change in proguard file so that it will not shrink the resources of drawable folder? – napster Aug 13 '19 at 08:15
  • I don't think there is an alternate solution. Or that's what I think. Wait for somebody else to answer. – Gaurav Mall Aug 13 '19 at 08:20
  • https://stackoverflow.com/a/57156980/7254873 – Sumit Shukla Aug 13 '19 at 10:32

2 Answers2

0

I created one layout & put image views in it with source set as image that were not displayed because of shrinking. Created one activity as well & assign that layout to it. As I didn't want to set shrink resource to false this solution worked for me.

napster
  • 687
  • 1
  • 8
  • 18
0

Try these two ways,
1. setBackgroundDrawable()
2. setImageBitmap(//convert drawable to bitmap in here)
Hope it helps. (please do implement first then reply)

Viraj S
  • 390
  • 2
  • 12