将子视图与Android中的父布局边缘对齐

时间:2013-07-03 17:51:45

标签: android android-layout imageview relativelayout

我有这个ImageView

<ImageView
    android:id="@+id/img_1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_alignParentTop="true"
    android:src="@drawable/my_img_1" />

这是RelativeLayout的孩子。我希望图片显示为page / parent的左上角。但事实并非如此。父母的左侧和顶部以及子视图之间大约有20dp margin / padding。我如何得到我想要的东西?

1 个答案:

答案 0 :(得分:1)

您期望的是应该发生什么。

听起来持有RelativeLayout上有20dp填充 - 这会导致你描述的行为。

确保您已从父RelativeLayout删除了填充!