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

Filed under:
|
|
|

Scope

Image bitmap have to be shown as imageView.setImageBitmap(bitmap) and scaled to fit UI. This could be done via:

  1. bitmap = Bitmap.createScaledBitmap(bitmap, newWidth, newHeight, true);
  2. 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

Related posts about android

Related posts about bitmap