How to change ListView height dynamically in Android?

前端 未结 7 890
小鲜肉
小鲜肉 2020-12-03 02:19

I need to change the height of a ListView dynamically in my app.

Is there any way to do that?

7条回答
  •  感动是毒
    2020-12-03 02:37

    for change height and width dynamically so, try this

    RelativeLayout.LayoutParams mParam = new RelativeLayout.LayoutParams((int)(width),(int)(height);
            listView.setLayoutParams(mParam);
    

    you can also use LayoutParams.FILL_PARENT or LayoutParams.WRAP_CONTENT instead of height & width

提交回复
热议问题