Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

Problem occurs while using high resolution image in device.

 imageview a;
InputStream ims = getAssets().open("sam.png");//sam.png=520*1400 device=320*480 or 480*800
Drawable d=Drawable.createFromStream(ims, null);
a.setLayoutParams(new        LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT));
a.setImageDrawable(d);

by using above code image leaves spaces on top and bottom to next contents or If I shrink an image by giving fixed px, its get blur image on its size. Anyway to solve this issue?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
103 views
Welcome To Ask or Share your Answers For Others

1 Answer

Try to create Bitmap instead of Drawable:

Bitmap bmp = BitmapFactory.decodeStream(ims);
a.setImageBitmap(bmp);

Looks like Android doing some tricks with drawables, depending of screen density.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...