How to Change list view's height progmmaticall

2019-03-16 00:18发布

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...?

2条回答
孤傲高冷的网名
2楼-- · 2019-03-16 00:58

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...........

查看更多
forever°为你锁心
3楼-- · 2019-03-16 01:05
    ViewGroup.LayoutParams params = listView.getLayoutParams();
    params.height = whatYouWant;
    listView.setLayoutParams(params);
    listView.requestLayout();
查看更多
登录 后发表回答