5

Is there any easy way to tile bitmap downloaded from URL on ImageView?

Preferably using Picasso or UniversalImageLoader.

I was thinking about getting image from Picasso cache and draw on canvas, but maybe there is more elegant way?

Thanks, Bartek.

  • possible duplicate of [Repeat drawable in imageview?](http://stackoverflow.com/questions/5159484/repeat-drawable-in-imageview) – Amanda S May 02 '14 at 17:56
  • I've seen that. It does work perfect for "static" drawables, but how to show tiled image downloaded from URL? – Bartosz Ostrowski May 02 '14 at 18:00

1 Answers1

0

This is what I did with Glide 4.0:

 Glide.with(this).asBitmap().load(url).into(new SimpleTarget<Bitmap>() {
      @Override
      public void onResourceReady(Bitmap resource, Transition<? super      Bitmap> transition) {
           BitmapDrawable bitmapDrawable = new BitmapDrawable(getResources(), resource);
           bitmapDrawable.setTileModeX(Shader.TileMode.REPEAT);
           bitmapDrawable.setTileModeY(Shader.TileMode.REPEAT);
           myImageView.setBackground(bitmapDrawable);
        }
 });
Ralphilius
  • 1,746
  • 2
  • 16
  • 28