如何在Android中动态更改ListView高度? [英] How to change ListView height dynamically in Android?

查看:73
本文介绍了如何在Android中动态更改ListView高度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在我的应用中动态更改ListView的高度.

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

有什么办法吗?

推荐答案

动态更改高度和宽度,请尝试

for change height and width dynamically so, try this

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

您还可以使用LayoutParams.FILL_PARENT或LayoutParams.WRAP_CONTENT代替height&宽度

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

这篇关于如何在Android中动态更改ListView高度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆