How to set the ListView Rows Height How to set the ListView Rows Height android android

How to set the ListView Rows Height


the problem is that you are mis-using the inflator, don't give null as the root node

if you pass null as the root node, all the size parameters you set in the xml fail to work

the correct code is

view = inflater.inflate(R.layout.lview_row, parent, false);

http://www.doubleencore.com/2013/05/layout-inflation-as-intended/


<?xml version="1.0" encoding="utf-8"?><LinearLayout  xmlns:android="http://schemas.android.com/apk/res/android"  android:orientation="vertical"  android:background="@drawable/list_selector"  android:padding="3dip"  android:layout_width="match_parent"  android:gravity="center"  android:layout_height="match_parent">    <TextView android:layout_height="wrap_content" android:text="ITEM"        android:layout_width="wrap_content" android:id="@+id/txtItem"        android:textAppearance="?android:attr/textAppearanceLarge"        android:textSize="15sp"        android:textStyle="bold"        android:textColor="#040404"></TextView>    <TextView android:layout_height="wrap_content" android:text="MANUFACTURER"        android:layout_width="wrap_content" android:id="@+id/txtItemTwo"        android:textAppearance="?android:attr/textAppearanceMedium"        android:textSize="14sp"        android:textColor="#FF7F50"        ></TextView></LinearLayout>

If you are having more than one line in your text then set your text as single line so that it will not come in second line and change your height of each row.


override method getView(int position, View convertView, ViewGroup parent) in your MyEventAdapter class and use view.setMinimumHeight(minHeight); to set minimum height of view.

set minimum height of view with in method `getView(int position, View convertView, ViewGroup parent)' as following:

public View getView(int position, View convertView, ViewGroup parent) {    ViewHolder title;    LayoutInflater inflater = activity.getLayoutInflater();    if (view == null) {        view = inflater.inflate(R.layout.lview_row, null);        view.setMinimumHeight(minHeight); //set minimum height of view here        title = new ViewHolder();        title.txtViewTitle = (TextView) view.findViewById(R.id.txtItem);        title.txtViewTitleTwo = (TextView) view.findViewById(R.id.txtItemTwo);        view.setTag(title);    } else {        title = (ViewHolder) view.getTag();    }    title.txtViewTitle.setText(listTitle.get(position));    title.txtViewTitleTwo.setText(listFullText.get(position));    return view;    }