GalleryView 中的图像在顶部和底部被剪裁

发布于 2024-11-14 12:55:19 字数 564 浏览 3 评论 0原文

我有一个 GalleryView(设置为 View.GONE),其中填充了不同形状和少量不同尺寸的图像(在合理的范围内,因此它们都可以缩放相同的量而没有问题),这是美好的。然后我将其设置为 View.VISIBLE。不幸的是,GalleryView 会裁剪列表中所有其他图像的顶部和底部,以匹配最短项目的大小。 GalleryView的layout_height设置为wrap_contents。

我希望 GalleryView 高度与最大图像的高度匹配,而不是最小图像的高度(另请注意,这将根据相关手机的 dpi 进行更改)。我将如何强迫或鼓励这样做?

编辑:这是一个老问题,但仍然是一个问题。但是,我现在发现它不会剪辑到最短的项目,而是剪辑到首先选择的项目。因此,如果我将图库初始化为已滚动到第二个项目,它们将剪辑到该项目。不幸的是,我似乎无法事先确定哪个项目是最大的并滚动到该项目(无论如何,这都不是一个很好的解决方案)。

再次编辑:这是一个示例图像。看看第二个项目是如何在顶部和底部剪裁的? 视觉错误示例。第一项和第三项都很好,但第二项的文本较长,被剪裁了。

I have a GalleryView (set to View.GONE) that is being filled with images that are different shapes and a small variety of different sizes (within a reasonable range, so they can all be scaled the same amount with no problems), which is fine. Then I set it to View.VISIBLE. Unfortunately, the GalleryView will clip the tops and bottoms of every other image in the list to match the size of the shortest item. GalleryView layout_height is set to wrap_contents.

I'd like the GalleryView height to match the height of the largest image, not the smallest (noting, also, that this will change based on the dpi of the phone in question). How would I force or encourage this?

Edit: This is kind of an old question, but it's still a problem. However, I have now discovered that it doesn't clip to the shortest item, it clips to the item that is selected at first. So if I initialize the Gallery to be already scrolled to the second item, they'll clip to that one. Unfortunately, I can't seem to determine beforehand which item is the largest and scroll to that (which wouldn't be a great solution anyway).

Edit again: Here's an example image. See how the second item is clipped at the top and bottom?
Example of visual error. The first and third items are fine, but the second has longer text which is clipped.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文