Android:如何调整图像大小以自动适应视图
我有 png 楼层地图图像。我使用下面的代码来设置默认图像大小以适合视图。
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;
}
如果您注意到了,我使用固定值只是为了使图像与视图相匹配。
任何关于如何根据其视图自动安装它的指导都是值得赞赏的。
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(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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你为什么不缩放图像?尝试 CENTER_INSIDE
why don't you scale images? try CENTER_INSIDE