Android 画廊中的图像缩放
我在图库视图中有两张图像。首先,我添加一张 80x80 的图像,然后添加一张更大的图像 (400x400)。我希望两个图像都显示为 80x80 以匹配第一个图像的大小。
如果我对大小进行硬编码,
image.setLayoutParams(new Gallery.LayoutParams(80, 80));
image.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
一切都会正常。但是,如果我尝试逃避硬编码,以防第一个图像发生更改,
image.setLayoutParams(new Gallery.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT));
image.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
大图像将显示为 400x80,并且不会缩放:只有它的中心切片可见。
如何使图库中的所有图像缩放以匹配第一个添加的图像的大小,而不直接指定该大小?
I have two images in a Gallery view. First I add a 80x80 image, and then a bigger one (400x400). I want both images to be displayed as 80x80 to match the size of the first image.
If I hardcode the size
image.setLayoutParams(new Gallery.LayoutParams(80, 80));
image.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
all goes OK. But if I try to evade the hardcoding in case that the first image will be changed
image.setLayoutParams(new Gallery.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT));
image.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
the big image is displayed as 400x80, and is not scaled: only the central slice of it is visible.
How can I make all the images in the Gallery to be scaled to match the size of the first added image without specifying that size directly?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试用
Try with