A custom Dialog box with a RelativeLayout contains a Button widget that won’t change its margins, regardless of direction. Here’s the 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:orientation="horizontal" android:background="#99000000">
<TextView android:id="@+id/dialogtitle" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:text="Some text" />
<TextView android:id="@+id/dialogtext" android:layout_width="300dp"
android:layout_height="wrap_content" android:textSize="15dp"
android:layout_alignParentLeft="true" android:layout_below="@id/dialogtitle"
android:paddingLeft="8dp" />
<Button android:id="@+id/dialogbuttoninfo" android:layout_width="80dp"
android:layout_height="wrap_content" android:text="Doesn't care about margins"
android:layout_alignParentRight="true" android:layout_marginLeft="128dp" />
</RelativeLayout>
Padding works but only moves the text inside the button. Any suggestions?
This seems crappy but have you tried putting it all in a
LinearLayoutinstead? or perhaps removingandroid:orientation="horizontal". I dont thinkRelativeLayoutcares about orientation from what I’ve seen. Also I think, but might be wrong, that if you do aLinearLayoutthen you won’t need to haveandroid:layout_alignParentLeft="true"in there either.After cleaning it up a bit (sorry but its so hard to read when its compressed as it was in the question) you also didn’t state where the last
TextView,dialogbuttoninfowas supposed to be relative to everything else, I think you have to do that forRelative layoutsto behave properly, I’ve had some squirrely things happen.