简体   繁体   English

Android:如何调整图片大小以自动适合View

[英]Android: How can I resize an image to be automatically fitted with the View

I have png floor map images. 我有png地板图图像。 I am using the below code to set the default image size to fit with the view. 我正在使用下面的代码来设置默认图像大小以适合视图。

imageView is the view inside my ImageSwitcher: imageView是我的ImageSwitcher内部的视图:

imageView.setImageMatrix(createDefaultMatrix());

private Matrix createDefaultMatrix() {
    Matrix matrix = new Matrix();
    matrix.setValues(new float[]{1.136f, 0.0f, -17.204117f,0.0f, 1.136f, 66.24078f,0.0f, 0.0f, 1.0f});
    matrix.postScale(1.1085271f, 1.1085271f, 198.08646f, 304.4192f);
    return matrix;
}

If you have notice, I am using fix values just to fit the image with the view. 如果您有注意到,我使用的是修复值,只是为了使图像适合视图。

Any guidance on how to do it automatically fitted against its View is appreciated. 任何有关如何自动将其安装到其视图中的指导都值得赞赏。

why don't you scale images? 为什么不缩放图像? try CENTER_INSIDE 尝试CENTER_INSIDE

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM