I have a listview with custom rows. In imageView1 I set an image, but it is smaller than the height of the row . The image size is 4x30px. When I set a 40×300 img size (programmatically), the row gets too big (I know the reason: wrap_content). How can I set that the image be streched in height to the height of the row?
holder.image.setImageDrawable(convertView.getResources().getDrawable(R.drawable.priority_4x30));
xml.file:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/icon"
android:focusable="false" />
<TextView android:id="@+id/textView1"
android:layout_width="180dip"
android:layout_height="wrap_content"
android:paddingTop="15dip"
android:paddingBottom="15dip"
android:textColor="#000000"
android:layout_toRightOf="@+id/imageView1">
</TextView>
<ImageView
android:id="@+id/imageView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/icon"
android:layout_toRightOf="@+id/textView1" />
<CheckBox android:id="@+id/checkBox1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="6sp"
android:focusable="false"
android:layout_toRightOf="@+id/imageView2">
</CheckBox>
</RelativeLayout>
You should make your relativelayout for each item have a static height
ex:
and then you can simply change your imageview to fill parent for its height