Reputation: 1011
In my application the user selects a bitmap and then i use the following code:
BitmapFactory.Options op= new BitmapFactory.Options();
Bitmap bitmap = BitmapFactory.decodeFile(path,op);
imageView.setImageBitmap(bitmap);
Unfortunately, sometimes ImageView
does not display anything
What can i do?
Upvotes: 1
Views: 3695
Reputation: 1228
I found this problem for Android 8 and low. There is no difference use method setImageBitmap
or setImageUri
: ImageView
will be blank sometimes. There is no any errors and you can get Bitmap
from ImageView
.
Solution.
Use width and height of Bitmap
for ImageView
no more then double screen size, better is to fit to the screen size.
Upvotes: 2
Reputation: 1011
Sometimes bitmap is too large. Thats why imageview turns blank! I think that here you can find what you need: http://developer.android.com/training/displaying-bitmaps/load-bitmap.html
Upvotes: 3