我的XML文件已定义: 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" />
和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" />
请问,如何在ListView中为TextView设置更高的高度值以查看两行文字?
答案 0 :(得分:3)
将list_item.xml 中的线性布局高度从32dp设置为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" />