ImageView
16lz
2021-12-04
Android的ImageView控件。
ImageView.ScaleType
- center
Center the image in the view, but perform no scaling.
- 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.
- 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.
- fit_center
Scale the image using CENTER.
- fit_end
Scale the image using END.
- fit_start
Scale the image using START.
- fit_xy
Scale the image using FILL.
- 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.
资料
- 如何缩放图片并保持宽高比http://stackoverflow.com/questions/2521959/how-to-scale-an-image-in-imageview-to-keep-the-aspect-ratio
更多相关文章
- Android圆形图片--自定义控件
- android基础控件(3)BottomNavigationView+FragmentLayout实现底层
- Android通过手势实现的缩放处理
- Android(安卓)VideoView播放视频
- android 移送控件
- android 拖动条改变屏幕亮度
- Android(安卓)WebView相关属性
- android 设置粗体
- Android动画效果 Android(安卓)Animation