tags:

views:

72

answers:

3

Hi,

I have a Relative Layout. Which has 2 buttons, side by side and it is right-aligned.

So this is my layout xml file. My question is there are no spacing between the right-most button and the right border of the RelativeLayout and between the 2 buttons. How can I add that? I play with android:paddingRight, but nothing helps.

Thank you.

<RelativeLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:paddingLeft="0dp" android:paddingRight="10dp">

    <Button android:id="@+id/1button" android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:paddingLeft="10dp" android:paddingRight="10dp"/>

    <Button android:id="@+id/1button" android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_toLeftOf="@id/1button"
        android:paddingLeft="10dp" android:paddingRight="10dp"/>
+1  A: 

You have duplicated ids for the buttons, try fixing that and see if it looks ok.

Otherwise, your layout looks good. However, if you fix the ID problem, there will be 20 dip padding on the right (10 from the layout and 10 from the button).

Brandon
+1  A: 
android:layout_margin="10dp"

or

android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
drawnonward
+1  A: 

Fix ids and try android:layout_marginRight="10dip"

Alex Volovoy