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


更多相关文章

  1. Android圆形图片--自定义控件
  2. android基础控件(3)BottomNavigationView+FragmentLayout实现底层
  3. Android通过手势实现的缩放处理
  4. Android(安卓)VideoView播放视频
  5. android 移送控件
  6. android 拖动条改变屏幕亮度
  7. Android(安卓)WebView相关属性
  8. android 设置粗体
  9. Android动画效果 Android(安卓)Animation

随机推荐

  1. Android高手进阶教程(九)之----Android(
  2. android为ImageView使用蒙层
  3. 对SqliteDatabase.findEditTable的改进
  4. Android修改源代码控制永不锁屏
  5. Tween动画
  6. Android颜色小工具
  7. [Android] Otto源码简析
  8. Android(安卓)-- RecyclerView
  9. adb 指令
  10. PagerBottomTabStrip