set ListView Parent Height - Android android.widget

Android examples for android.widget:ListView

Description

set ListView Parent Height

Demo Code

import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.ListAdapter;
import android.widget.ListView;

public class Main{

    public static void setListViewParentHeight(ListView listView, int height) {

        LinearLayout linearLayout = (LinearLayout) listView.getParent();
        android.widget.LinearLayout.LayoutParams params = new android.widget.LinearLayout.LayoutParams(
                android.widget.LinearLayout.LayoutParams.MATCH_PARENT,
                height);//from w ww .ja v  a 2s .c o  m
        linearLayout.setLayoutParams(params);

    }

}

Related Tutorials