我定义了以下布局:
<LinearLayout>
<TextView />
<RelativeLayout>
<TextView>
<Button>
<Button>
</RelativeLayout>
<LinearLayout>
现在我想获得 RelativeLayout 的高度(我想以编程方式指定其子项的高度):
View rel = findViewById(R.id.RelativeLayout01);
int width = rel.getWidth();
int height = rel.getHeight();
但是size returned is 0
. 我如何获得 RelativeLayout 的大小(它主要是上面的伪代码,但两个布局在 xml 中都有一个“fill_parent”的高度/宽度)