android- How to get the width and height of the list view dynamically

前端 未结 2 1022
梦谈多话
梦谈多话 2021-01-14 16:41

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 t

2条回答
  •  猫巷女王i
    2021-01-14 17:00

    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());
    
    }
    

提交回复
热议问题