LuckyLuke
LuckyLuke

Reputation: 49077

How to set a standard height of a listview row

In iOS programming I have to implement (or at least if I don't want the default one...) an method which returns the height of the row. I am probably blind because I can't find the method where I set the height of the row in a listview in Android.

I have created custom row layouts, so I start to think that I set the height in the parent layout manager in the XML. Can anyone confirm that this is the way to do it? Or is it a method?

Upvotes: 0

Views: 945

Answers (2)

jimduchek
jimduchek

Reputation: 111

You'll need to set the height in the layout xml for the row itself. If you absolutely want every row to be the same height, set:

android:minHeight="80dp" 
android:maxHeight="80dp"

in your base layout (Should be a LinearLayout or RelativeLayout, likely) of the listview row. Note you can do:

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

to be inline with (most) other applications.

Upvotes: 2

Yashwanth Kumar
Yashwanth Kumar

Reputation: 29121

Yes, the only way to set the height of the row is to mention it's dimensions in the xml ,for the list item or you can also set the height of the list item in the getView() method of listView if you have a custom Adapter. There is no listView method as such to define the height of the row.

Upvotes: 1

Related Questions