Device
Device

Reputation: 1011

Calling setImageBitmap not always work for ImageView

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

Answers (2)

Style-7
Style-7

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

Device
Device

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

Related Questions