RelativeLayout具有相同的宽度和高度

时间:2015-09-03 12:54:19

标签: android android-layout android-relativelayout

我有一张照片列表,每张照片都有一些文字。我希望每张照片都水平填充屏幕,并希望高度与宽度相同

尝试完成像

这样的事情
$meta['https://example.com/domainchecker.php']['title'] = "Domain Search";
$meta['https://example.com/domainchecker.php']['description'] = "Description etc";
$meta['https://example.com/domainchecker.php?search=bulk']['title'] = "Domain Search Bulk";
$meta['https://example.com/domainchecker.php?search=bulk']['description'] = "Description etc";

我怎么能做到这一点?

由于我将使用recycleview,我可以在运行时编辑高度。

3 个答案:

答案 0 :(得分:0)

以编程方式查找布局的宽度,并将该值设置为布局的高度。

//get Width
int width=layout.getWidth();

//set height
layout.getLayoutParams().height=width;

答案 1 :(得分:0)

XML不是动态的。屏幕测量必须在onCreate期间用Java完成。

{{1}}

答案 2 :(得分:0)

should be like this,if you want height for full screen use match_parent also

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"

/>