GridView 行高 [英] GridView row height

查看:24
本文介绍了GridView 行高的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个显示图像的 GridView,不幸的是,这些图像的大小不同.它们显示在两行文本之间:

I have a GridView that displays images, which are, unfortunately, of different sizes. They are shown in between two lines of text:

text1.1                text1.2
ImageView(IMAGE1)      ImageView(IMAGE2)
text2.1                text2.2

text3.1
ImageView(IMAGE3)
text4.1

等等....

如果 IMAGE1 和 IMAGE2 的高度相同,一切都很好,但是如果 IMAGE1 比 IMAGE2 ,text2.1 将遇到 text3.1(填充似乎没有多大帮助,因为当图像具有相同高度时它太多了).

If IMAGE1 is the same height as IMAGE2, everything is fine, but if IMAGE1 is longer than IMAGE2, text2.1 will run into text3.1 (padding doesn't seem to help much, as there's too much of it when images are of the same height).

我知道有一种方法可以拉伸 ImageView 中的图像,使它们具有相同的高度,但是是否可以保持图像原样并以某种方式设置行高?

I know there's a way to stretch the images in the ImageView so they are the same height, but is it possible to keep images as is and set the row height somehow?

推荐答案

您可以根据您在行高中放置的内容来控制行高.由于您的单元格似乎有多个小部件,因此它们可能被包裹在 LinearLayout 或其他东西中.将您的 LinearLayouts 设置为某个特定的高度,并且行都将是该高度.

You are in control over your row heights, by virtue of what you put in them. Since your cells appear to have more than one widget, they are presumably wrapped in a LinearLayout or something. Set your LinearLayouts to be some specific height, and the rows will all be that height.

就个人而言,如果您要在每个单元格的基础上在每个图像的上方和下方显示文本,我认为您应该调整图像的大小.

Personally, I think you should be resizing your images if you are going to have text above and below each image on a per-cell basis.

这篇关于GridView 行高的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆