I have a RelativeLayout
for a row that goes inside a ListView
. The row looks like,
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/relativeLayout1"
android:layout_width="wrap_content"
android:layout_height="fill_parent">
<ImageView
android:id="@+id/placeDetailIcon_Img"
android:layout_height="50dp"
android:layout_width="50dp"
android:layout_alignParentLeft="true"
android:paddingBottom="20dp"
android:paddingTop="20dp"
android:paddingLeft="20dp"
android:paddingRight="20dp"/>
</RelativeLayout>
I also tried it with margin:
<ImageView
android:layout_height="50dp"
android:layout_width="50dp"
android:id="@+id/placeDetailIcon_Img"
android:layout_alignParentLeft="true"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:layout_marginLeft="10dp"
android:layout_marginBottom="10dp">
Neither apply the margin or padding around the ImageView
. How do create this type of spacing?
you can use this its work with me :
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/relativeLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ImageView
android:id="@+id/imageView1"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="15dp"
android:layout_marginTop="15dp" />
</RelativeLayout>
hope this helps.
For anyone else who is looking for a solution to this - from the docs:
http://developer.android.com/reference/android/widget/RelativeLayout.html
"Note that you cannot have a circular dependency between the size of the RelativeLayout and the position of its children. For example, you cannot have a RelativeLayout whose height is set to WRAP_CONTENT and a child set to ALIGN_PARENT_BOTTOM."
It seems also that there is some odd behavior if you put a relativeView inside of a scrollview.
In my case I had set the relativeLayout to wrap_content and then tried to add marginBottom to an ImageView with the ALIGN_PARENT_BOTTOM attribute. When I set the height explicitly it finally worked.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With