简体   繁体   English

如何在列表视图中设置固定图像高度 100%

[英]how to set fix image height in list view 100%

Here I have used code as,space is occurred how i can remove this space在这里我使用了代码,因为出现了空格我如何删除这个空格在此处输入图片说明

<ImageView
        android:id="@+id/icon"
        android:layout_width="110dp"
        android:layout_height="110dp"
        android:contentDescription="@string/image"
        android:layout_alignParentRight="true"
        android:paddingRight="5dp" /

> >

在 ImageView 中使用它

 android:scaleType="fitXY"

Try android:layout_height="match_parent" instead of 110dp.尝试android:layout_height="match_parent"而不是 110dp。

Never hardcode values like that, always use layouts, weights, proportions etc. because EVEN if it looks good on your device, it might look wrong on a different device with a different screen size/pixel density.永远不要硬编码这样的值,始终使用布局、权重、比例等。因为即使它在您的设备上看起来不错,在具有不同屏幕尺寸/像素密度的不同设备上也可能看起来不正确。

You are getting that extra space because of your Text View (ex:"Google is a Multinational Publicly Traded Organization") varies in number of lines, some text have 3 lines and some text 2 lines, Ur image height works perfectly for 2 lines text but for 3 lines text it will get a space.由于您的文本视图(例如:“Google 是一家跨国上市公司”)的行数不同,您获得了额外的空间,有些文本有 3 行,有些文本有 2 行,您的图像高度非常适合 2 行文本但对于 3 行文本,它将获得一个空格。 So My suggestion is you can restrict your item text view for maxlines is equal to two and it will fix ur problem.所以我的建议是您可以将 maxlines 的项目文本视图限制为等于 2,这将解决您的问题。

Insert This In Your ListView Item TextView将此插入您的 ListView 项 TextView

android:maxLines="2"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM