我把一个 LinearLayou 的高度设置成 match_parent :
<LinearLayout
android:id="@+id/list_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
我想获取 LinearLayout 的高度。
使用下面的代码:
LinearLayout ll_list = (LinearLayout)findViewById(R.id.list_layout);
int h = ll_list.getHeight();
但是返回null。
如何处理这个问题?
这个获取的时间不对吧,不应该在onCreate的时候获取,那个时候控件还没有渲染完毕,换个地方获取,或者直接用delay的方式获取
onCreate中LinearLayout不一定绘制完成了,所以获取的高度均为0.