11

I've got all of the images I need for my app, and I'm trying to speed it up and make it silky smooth, so I have been using Glide to load the images and it works in other areas of my app but not in my viewpager.

In my fragment I'm trying to load my image like so

Glide.with(this).load(R.drawable.my_drawable).into(myImageView);

and nothing happens or appears and I don't get an exception or any sort of error message from Glide.

Sam Judd
  • 7,317
  • 1
  • 38
  • 38
Jacob Collins
  • 454
  • 2
  • 4
  • 9

4 Answers4

14

I know this question is long since closed but I found a good solution for this by using the placeholder or error image instead. So you might try

Glide.with(<<MyActivity>>)
    .load("")
    .placeholder(<<myDrawable>>)
    .into(imageView);

Not sure this is what you wanted but if there are others having the same issue, at least this seems to work with a minimum of work. :)

Tobias Reich
  • 4,952
  • 3
  • 47
  • 90
  • Struggling from 1 hr to load a picture from resource id in alert dialog. Place holder did the trick. – Madhu Jan 23 '17 at 09:08
  • 1
    .placeholder() is deprecated now. Use `Glide.with(activity).load("").apply(RequestOptions().placeholder(resourceId)).into(imageView)` instead. – Joonsoo Feb 08 '19 at 06:12
5

Check out the Debugging and Error Handling wiki page to enable logging. That should tell you if the load is failing and why.

If you see no error logs, it's possible that your View doesn't have a size, either because its size is 0, or because it hasn't gone through layout (visibility set to View.GONE etc). If so, you can test check by adding a call to override() with any valid width and height (try 400, 400 or something just to test).

If calling override() fixes the issue, take a look at your xml and see if you can change your view to either have a fixed size, or to at least eventually end up with a valid size. If all else fails, you can always call override() with Target.SIZE_ORIGINAL as the width and height.

Sam Judd
  • 7,317
  • 1
  • 38
  • 38
1

Tobias Reich's way generates a bunch of warning logs cause load url is "". If you don't want warning logs,

Try this:

int drawableIdentifier = activity.getResources().getIdentifier("my_drawable_image_name", "drawable", activity.getPackageName());
Glide.with(activity)
     .load(drawableIdentifier)
     .into(imageView);
Joonsoo
  • 788
  • 1
  • 13
  • 15
0

If you are using a Vector or SVG, your version of Glide might not support this and fail to load.

Frank
  • 12,010
  • 8
  • 61
  • 78