[英]Different ImageView size in a listView
I have a custom listview with ImageView and EditText , my problem is, with different image the size of imageview is different, like in photo. 我有一个带有ImageView和EditText的自定义listview,我的问题是,对于不同的图像,imageview的大小是不同的,就像在照片中一样。 How can I make sure that all images have the same size?
如何确定所有图像的尺寸相同?
This is my XML code : 这是我的XML代码:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:weightSum="1">
<ImageView
android:id="@+id/imageView1"
android:layout_width="150px"
android:layout_height="150px"
android:adjustViewBounds="true"
android:layout_weight="0.1"
android:scaleType="fitXY"
android:layout_marginBottom="1dp"/>
To deal with different aspect ratio images your best approach is to choose a aspect ratio in your layout and center crop your images so they fill the available space. 要处理不同的长宽比图像,最好的方法是在布局中选择一个长宽比,然后对图像进行中心裁剪,以使其占据可用空间。
<ImageView
android:layout_width="160dp"
android:layout_height="90dp"
android:scaleType="centerCrop" />
Well for better size, create linear layouts for each row containing an Imageview and Edittext . 为了获得更好的尺寸,请为每个包含Imageview和Edittext的行创建线性布局。 You have set
ScaleType
to fitXY
and that is good. 您已将
ScaleType
设置为fitXY
,这很好。 Now use dp
or fill_parent
for Imageview size. 现在使用
dp
或fill_parent
作为Imageview的大小。
(Posted on behalf of the OP) . (代表OP张贴) 。
I have solved this - I have simply remove this android:layout_weight="0.1"
. 我已经解决了-我只需删除此
android:layout_weight="0.1"
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.