0

Given:

  • A number of images (10 - 15) residing in assets folder (as practice shows, the better approach is to keep high-resolution images in assets)
  • Android UI thread (caching drawables in advance is already made in a background thread)

The issue:

Need to display all the images one on another smoothly and not blocking UI thread after the images are drawn.

Already used approaches:

  • Dynamically create a required number of ImageView and then call .setImageDrawable(). This takes a lot of time but the worst thing is that the UI thread is being blocked even after all the images are drawn on their ImageView.
  • Create a LayerDrawable object and pass as argument an array of the required Drawables. Then put it on an ImageView also by calling .setImageDrawable(). This option behaves the same like the one described above.

Is there a way to solve this issue? Or Android devices not capable to cope with it?

krsnk
  • 267
  • 1
  • 10

2 Answers2

0

Try Picasso library:

http://square.github.io/picasso/

It has support for resources:

Picasso.with(context).load(R.drawable.landing_screen).into(imageView1);
Picasso.with(context).load("file:///android_asset/DvpvklR.png").into(imageView2);
Picasso.with(context).load(new File(...)).into(imageView3);
Gabo
  • 11
  • 4
  • I have already used Glide, but the rendering don't get better. – krsnk Sep 20 '17 at 06:05
  • Take a look at Glide and Picasso comparison: https://medium.com/@multidots/glide-vs-picasso-930eed42b81d Glide tends to use less memory but also is softly slower than Picasso. Both libraries has similar syntax so you can just give a try with Picasso. – Gabo Sep 20 '17 at 06:26
  • Image loading libraries, such as Picasso, Glide, Fresco, ImageLoader are great for asynchoronously caching, managing memory, loading images from network, but inside, when everything's done, they also call .setImageDrawable or .setImageBitmap from Android SDK, and only after that Android starts drawing UI by updating an ImageView. And here is where my issue is, it doesn't depend on how images were loaded but how they are dispalyed. – krsnk Sep 20 '17 at 06:37
0

If you are requiring a smooth transition between images, please try viewFlipper https://developer.android.com/reference/android/widget/ViewFlipper.html

Basically you can add imageView inside the viewflipper and start animation to move from previous to next image. I am not sure if you need user interactions like scrolling or not. You can try viewPager if user need to scroll betweens images.

Please note that Glide does provide some transition effects for switching between placeholder and image to display. But transition between images are not included, you can have a look here http://bumptech.github.io/glide/doc/transitions.html

I hope this helps because i am not sured that if you are asking the transition between images or rendering images.

Michael Lam
  • 415
  • 3
  • 9
  • Thank you for the answer but I actually need to draw images one on top of another, in a stack way. I need no pages of images or any animations on them. – krsnk Sep 20 '17 at 07:16
  • do you have desired layout picture as a reference? – Michael Lam Sep 20 '17 at 07:22
  • Sorry for that, I cannot give a picture. But it is about 2000*1500 px, webp format and ~100Kb of size. – krsnk Sep 20 '17 at 07:30
  • are you just trying to stacking up the images? Do you need to interact with them like flipping to next image or something like that. May be you can take a look at this library https://github.com/blipinsk/FlippableStackView – Michael Lam Sep 20 '17 at 07:37
  • No interation is expected, the only thing what will interact with pictures is pulling or pushing on top. No animations or transitions needed. – krsnk Sep 20 '17 at 07:40
  • You can try to render it in batches so UI Thread won't burden too much so it won't block the thread. – Michael Lam Sep 20 '17 at 08:06