Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

android listview item height

Why when i use SimpleCursorAdapter for ListView i have items height in ListView like this - listview image

(My code based on this)

But when using arrays Listview items have big height

listview big

(I learn listview based on this)

Row layout for item listview is

<?xml version="1.0" encoding="utf-8"?>
<TextView android:id="@+id/text1"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>

So My question is why there is a difference in row heights when using ArrayAdapter and SimpleCursorAdapter?

like image 924
olegi Avatar asked Nov 22 '10 09:11

olegi


2 Answers

  android:textAppearance="?android:attr/textAppearanceLarge" 

seemed no effect.

  android:minHeight="?android:attr/listPreferredItemHeight" 

changed the height for me

like image 67
Bamboo Avatar answered Oct 29 '22 17:10

Bamboo


The trick for me was not setting the height -- but instead setting the minHeight. This must be applied to the root view of whatever layout your custom adapter is using to render each row.

like image 37
Evan Avatar answered Oct 29 '22 15:10

Evan