Reputation: 1050
I am facing problem in setting the height of my list view's item. Below is what I am having in my layout xml file
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:minHeight="48dp">
<ImageView
android:id="@+id/imageView"
android:contentDescription=""
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_marginLeft="1dp"
android:layout_alignParentTop="true"/>
<TextView
android:layout_alignBottom="@+id/imageView"
android:id="@+id/text1"
android:layout_width="97dp"
android:layout_height="wrap_content"
android:textAppearance="?attr/textAppearanceListItemSmall"
android:gravity="center_vertical"
android:paddingLeft="36dp"
android:paddingRight="16dp"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:textColor="#fff"
android:minHeight="?android:attr/listPreferredItemHeight"/>
</RelativeLayout>
The problem is that some of the text is going out of the list item's height. Can you please help me what I need to do here? Thanks in advance.
Upvotes: 1
Views: 1509
Reputation: 1844
Use below layout for you listitem,
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="10dp"
>
<ImageView
android:id="@+id/imageId"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="1dp"
android:layout_gravity="center_vertical|center_horizontal"
android:src="@drawable/imge"
/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_marginLeft="5dp"
android:layout_gravity="center_vertical"
>
<TextView
android:id="@+id/textIde"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Text"
/>
</LinearLayout>
</LinearLayout >
Upvotes: 0
Reputation: 1111
Remove this attribute android:minHeight="?android:attr/listPreferredItemHeight"
from the TextView component.
Upvotes: 1