Why when i use SimpleCursorAdapter for ListView i have items height in ListView like this -
(My code based on this)
But when using arrays Listview items have big height
(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?
The height of list view items are adjusted based on its contents. In first image, no content. so height is very minimum. In second image, height is increased based on the size of the text. Because, you specified android:layout_height="wrap_content".
You need to use padding on the list item layout so space is added on the edges of the item (just increasing the font size won't do that).
This is my solution(There is a nested LinearLayout):
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.
I did something like that :
You must put the both fields textView.setHeight(30); textView.setMinimumHeight(30); or it won't change anything. For me it worked & i had the same problem.
Here is my solutions; It is my getView() in BaseAdapter subclass:
Here i have set ListItem's minimum height to 100;