Pavel Matras
Pavel Matras

Reputation: 349

TextView item height in ListView

please I have this layout in my app: enter image description here

and my XML files are defined: content_main.xml:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context="cz.pavelmatras.prazskyhajzly.MainActivity"
tools:showIn="@layout/activity_main">

<ListView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/lvSeznamHajzlu"
    android:layout_alignParentTop="true"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true" />

and list_item.xml:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="32dp"
android:gravity="center"
android:orientation="horizontal"
android:padding="4dp" >

<ImageView
    android:id="@+id/ivImage"
    android:layout_width="48dp"
    android:layout_height="wrap_content"
    android:layout_marginRight="16dp"
    android:src="@drawable/wheel_chair" />

<TextView
    android:id="@+id/tvText"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:text="TextView" />

Please, how can I set higher height value for TextView in ListView to see both lines of text?

Upvotes: 0

Views: 369

Answers (1)

Deepak Goyal
Deepak Goyal

Reputation: 4907

set the height of linear layout in list_item.xml from 32dp to wrap_content

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="horizontal"
android:padding="4dp" >

<ImageView
    android:id="@+id/ivImage"
    android:layout_width="48dp"
    android:layout_height="wrap_content"
    android:layout_marginRight="16dp"
    android:src="@drawable/wheel_chair" />

<TextView
    android:id="@+id/tvText"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:text="TextView" />

Upvotes: 3

Related Questions