How to Change list view's height progmmaticall

2019-03-16 01:10发布

问题:

I want to know how to change height of the list view programmatically.

Is it possible to change the child items height for individual list item...?

回答1:

Noby if you want to change the hight of Child items you add new item_row layouts for each child and change it height as you want and inflate it using View getView method ...........

If youi want to change height of listview....

list.setLayoutParams(new RelativeLayout.LayoutParams(155, 115));

LayoutParams.fill_parent and LayoutParams.wrap_content

enter your listview width and height in paranthases.,,,, and in your xml file only listiew in relative layout...........



回答2:

    ViewGroup.LayoutParams params = listView.getLayoutParams();
    params.height = whatYouWant;
    listView.setLayoutParams(params);
    listView.requestLayout();