ImageView source scaling done right. How?
Posted
by
Aleksey Malevaniy
on Stack Overflow
See other posts from Stack Overflow
or by Aleksey Malevaniy
Published on 2011-11-17T17:44:18Z
Indexed on
2011/11/17
17:51 UTC
Read the original article
Hit count: 203
Scope
Image bitmap have to be shown as imageView.setImageBitmap(bitmap) and scaled to fit UI. This could be done via:
bitmap = Bitmap.createScaledBitmap(bitmap, newWidth, newHeight, true);
xml's ImageView attributes such as
android:layout_width="newWidth" android:layout_height="newHeight" android:adjustViewBounds="true" android:scaleType="fitCenter"
Problem
Which way is better for performance? I prefer xml 'cause this is UI specific problem and I prefer to use xmls for UI definition. Also we set width/height values in dp, it means we have the same UI for different screens. Thanks!
© Stack Overflow or respective owner