This is probably something simple, but I couldn't get it right. I am using a custom list fragment and I am trying to add some margin to it. Here's my xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/rounded_courner" >
<TextView
android:id="@+id/textViewProductName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:text="TextView" />
<ImageView
android:id="@+id/imageViewProductPic"
android:layout_width="250dp"
android:layout_height="250dp"
android:layout_below="@+id/textViewProductName"
android:layout_centerHorizontal="true"
android:layout_marginTop="16dp"
android:src="@drawable/counter_bg" />
<TextView
android:id="@+id/textViewProductPrice"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/imageViewProductPic"
android:layout_centerHorizontal="true"
android:text="TextView" />
</RelativeLayout>
and the outcome is
Now I would like to add margins on the top right bottom left. So the borders aren't so stick to the sides and to each other. I've try doing this
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="30dp"
android:layout_marginRight="30dp"
android:layout_marginTop="30dp"
android:layout_marginBottom="30dp"
android:background="@drawable/rounded_courner" >
But it doesn't work. Here's the outcome:
Does anyone has any idea to achieve the margin in my case? Thank you in advance for your help.