android:layout_marginRight属性不适用于RelativeLayout

meh*_*meh 6 android android-layout

我有一个内部相对布局有2个图像,当我设置android:layout_marginRight属性时它没有做任何事情.

这是我的代码:

<RelativeLayout
    android:id="@+id/location_image_layout"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentRight="true"
    android:layout_centerVertical="true" >

    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginRight="80dp" />

    <ImageView
        android:layout_width="69.33dp"
        android:layout_height="72dp"
        android:background="@drawable/icon"
        android:layout_centerInParent="true" />

</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)

小智 22

问题在于布局的属性android:layout_width.当它被设置为时"wrap_content",android:layout_marginRight它将不起作用,而是仅当它被设置为时"fill_parent",android:layout_marginRight它将起作用.