开发者

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

开发者 https://www.devze.com 2023-04-08 09:51 出处:网络
I have png floor map images. I am using the below code to set the default image size to fit with the view.

I have png floor map images. 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.setImageMatrix(开发者_Go百科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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号