ImageView

Android的ImageView控件。

ImageView.ScaleType

  1. center
    Center the image in the view, but perform no scaling. 
  2. center_crop
    Scale the image uniformly (maintain the image's aspect ratio) so that both dimensions (width and height) of the image will be equal to or larger than the corresponding dimension of the view (minus padding). The image is then centered in the view.
  3. center_inside
    Scale the image uniformly (maintain the image's aspect ratio) so that both dimensions (width and height) of the image will be equal to or less than the corresponding dimension of the view (minus padding). The image is then centered in the view.
  4. fit_center
    Scale the image using CENTER.
  5. fit_end
    Scale the image using END.
  6. fit_start
    Scale the image using START.
  7. fit_xy
    Scale the image using FILL.
  8. matrix
    Scale using the image matrix when drawing. The image matrix can be set using setImageMatrix(Matrix).

上面说到的center、end、start、fill属性都在Matrix.ScaleToFit里。

Matrix.ScaleToFit

1、center

Compute a scale that will maintain the original src aspect ratio, but will also ensure that src fits entirely inside dst.


2、end

Compute a scale that will maintain the original src aspect ratio, but will also ensure that src fits entirely inside dst.


3、start


Compute a scale that will maintain the original src aspect ratio, but will also ensure that src fits entirely inside dst.


4、fill

Scale in X and Y independently, so that src matches dst exactly.

资料


  1. 如何缩放图片并保持宽高比http://stackoverflow.com/questions/2521959/how-to-scale-an-image-in-imageview-to-keep-the-aspect-ratio


你可能感兴趣的:(android,imageview)