If I add a carriage return in a button an extra bit of "margin" (for a lack of better explanation) appears at the top:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:local="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ff992a2a">
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="200dp">
<Button
android:layout_width="250dp"
android:layout_height="100dp"
android:text="Extend" />
<Button
android:layout_width="250dp"
android:layout_height="100dp"
android:text="Accept
0:23"/>
</LinearLayout>
</RelativeLayout>
If I don't add the carriage return, it aligns perfectly:
how can I stop the extra 'margin' appearing ? I tried setting the android:lines="2"
and and/or android:singleline="false"
but nothing seems to help.
You need to set android:gravity="center"
in your LinearLayout
SAMPLE CODE
<?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="#ff992a2a">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="200dp"
android:gravity="center"
android:orientation="horizontal">
<Button
android:layout_width="250dp"
android:layout_height="100dp"
android:text="Extend" />
<Button
android:layout_width="250dp"
android:layout_height="100dp"
android:text="Accept
0:23" />
</LinearLayout>
</RelativeLayout>