我的列表视图有一个问题,其中包含一个ImageVIEw和每个项目一些TextVIEw.
或多或少,有两行TextVIEws和一个ImageVIEw(XX)应该采用两行:
|XX| TextVIEw 1 TextVIEw 2|XX| TextVIEw 3 TextVIEw 4
我的问题是当我在ImageVIEw中更改图像时.我的目标是使imagevIEw的高度与两个textvIEw的高度相同.但是我的图像是400×300,因此将imagevIEw扩展为包含它.我试图用getHeight或getMeasuredHeight来获取imageVIEw的高度,以在将位图放入imageVIEw之前重新调整位图的大小,这是行不通的.
我的列表视图布局是:
<relativeLayout xmlns:androID="http://schemas.androID.com/apk/res/androID"androID:layout_wIDth="fill_parent"androID:layout_height="fill_parent"androID:orIEntation="vertical" ><ImageVIEw androID:ID="@+ID/List_poi_image" androID:layout_wIDth="wrap_content" androID:layout_height="wrap_content" androID:layout_alignParentleft="true" androID:layout_alignParenttop="true" androID:scaleType="centerCrop" androID:contentDescription="@string/points_of_interest_activity_image_content_description" /><TextVIEw androID:ID="@+ID/List_poi_name" androID:layout_wIDth="wrap_content" androID:layout_height="wrap_content" androID:layout_alignParenttop="true" androID:layout_toRightOf="@+ID/List_poi_image" androID:textAppearance="?androID:attr/textAppearanceLarge" /><TextVIEw androID:ID="@+ID/List_poi_description" androID:layout_wIDth="wrap_content" androID:layout_height="wrap_content" androID:layout_alignleft="@+ID/List_poi_name" androID:layout_below="@+ID/List_poi_name" androID:textAppearance="?androID:attr/textAppearanceMedium" />
…
谢谢你的帮助!
解决方法:
为imagevIEw设置一些固定的高度,并设置imageVIEw的比例类型为FIT_XY或CENTER_INSIDE.无论宽高比如何,FIT_XY都会将图像缩放到所需的宽度和高度,因此图像可能会拉伸,CENTER_INSIDE将按照给定的尺寸缩放图像,并保持图像的长宽比,因此图像看起来比可用空间小.
总结以上是内存溢出为你收集整理的Android Listview图片大小全部内容,希望文章能够帮你解决Android Listview图片大小所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)