I have a custom ListView
and adapter
, and this is the code for my listview_item.xml
:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<ImageView
android:id="@+id/background"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop" />
<TextView
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_marginLeft="17.0dip"
android:fontFamily="sans-serif-condensed"
android:paddingTop="17.0dip"
android:textColor="@color/white"
android:textSize="24.0dip" />
<TextView
android:id="@+id/description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@id/title"
android:layout_marginLeft="18.0dip"
android:layout_marginTop="-3.0dip"
android:fontFamily="sans-serif-condensed"
android:textColor="#ffaaaaaa"
android:textSize="13.0dip" />
<Button
android:id="@+id/btnRanks"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:focusable="false"
android:focusableInTouchMode="false"
android:text="Ranks" >
</Button>
</RelativeLayout>
I want to set an image as the background of each list
item, but when I call imageView.setImageDrawable(drawable);
, I get a listview
that looks like this: . You can see that the image fills the entire
width
of the listview
, but not the height
. How do I get the image to fill the listview
's height as well?
By the way, this is the intended background image: