【发布时间】:2010-09-18 13:36:28
【问题描述】:
我定义了以下布局:
<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”)
【问题讨论】:
标签: android android-layout android-relativelayout