android-如何动态获取列表视图的宽度和高度 [英] android- How to get the width and height of the list view dynamically

查看:122
本文介绍了android-如何动态获取列表视图的宽度和高度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用程序,我想用适配器显示列表视图。但我想获取列表视图当前的高度和宽度(生成使用适配器列表后的意思)。如何得到它。任何人可以帮助我。

In my application i want display list view using adapter. But i want get the current height and width of the list view (means after generating the list using adapter). how to get it. can anybody help me.

感谢

推荐答案

使用的getWidth()的getHeight() ListView控件的方法 onWindowFocusChanged 获得的宽度和高度。

Use getWidth() and getHeight() method of ListView in onWindowFocusChanged to get the width and height.

@Override
public void onWindowFocusChanged(boolean hasFocus) {
    super.onWindowFocusChanged(hasFocus);


    System.out.println("Width:" + listview.getWidth());
    System.out.println("Height:" + listview.getHeight());

}

这篇关于android-如何动态获取列表视图的宽度和高度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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