Reputation: 83
I am loading a bitmap asynchronous (ASyncTask) to the ImageView (its a background picture). The user can pick a custom background picture. When I start the application, I am loading the bitmap to the ImageView, but that takes some time (like 0.3 seconds). In this 0.3 seconds, I see the default background (black screen). I do like to see the custom background immediately.
How can I achieve this?
EDIT
With Glide I get exactly the same result, again a black screen for half a second.
If I use this code, without async, it works, but is good practise?
inputStream = new FileInputStream(createFile());
return BitmapFactory.decodeStream(inputStream);
Upvotes: 0
Views: 1009
Reputation: 3648
Take a look at Picasso Library
http://square.github.io/picasso/
It works like this :
Picasso.with(context).load("http://i.imgur.com/DvpvklR.png").into(imageView);
With internal storage bitmap :
Picasso.with(context).load(new File(path)).into(imageView);
You can add an image that will be displayed during loading :
.placeholder(getResources().getDrawable(R.drawable.default_image))
Upvotes: 1