Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid: Align many buttons nicely
    primarykey
    data
    text
    <p>I have a RelativeLayout with 12 buttons, I want to align them nicely in the center of the screen and with equal distance to each others and equal left and right margins (like calculator buttons or telephone buttons). What I have done is in this XML file and the result in the pic, but it is still not perfect. Do you guys have any better solution for this?</p> <p><img src="https://i.stack.imgur.com/VJFJw.png" alt="enter image description here"></p> <pre><code> &lt;RelativeLayout android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:id="@+id/tabview1"&gt; &lt;TextView android:id="@+id/logo" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:text="www.fasttest.me" android:textColor="@android:color/white"/&gt; &lt;Button android:id="@+id/ql0" android:layout_width="@dimen/qlbutton_width" android:layout_height="@dimen/qlbutton_height" android:layout_marginTop="100dp" android:layout_marginLeft="10dp" android:text="b0" /&gt; &lt;Button android:id="@+id/ql1" android:layout_width="@dimen/qlbutton_width" android:layout_height="@dimen/qlbutton_height" android:layout_marginTop="100dp" android:layout_marginLeft="80dp" android:text="b1" /&gt; &lt;Button android:id="@+id/ql2" android:layout_width="@dimen/qlbutton_width" android:layout_height="@dimen/qlbutton_height" android:layout_marginTop="100dp" android:layout_marginLeft="150dp" android:text="b2" /&gt; &lt;Button android:id="@+id/ql3" android:layout_width="@dimen/qlbutton_width" android:layout_height="@dimen/qlbutton_height" android:layout_marginTop="100dp" android:layout_marginLeft="220dp" android:text="b3" /&gt; &lt;Button android:id="@+id/ql4" android:layout_width="@dimen/qlbutton_width" android:layout_height="@dimen/qlbutton_height" android:layout_marginTop="180dp" android:layout_marginLeft="10dp" android:text="b4" /&gt; &lt;Button android:id="@+id/ql5" android:layout_width="@dimen/qlbutton_width" android:layout_height="@dimen/qlbutton_height" android:layout_marginTop="180dp" android:layout_marginLeft="80dp" android:text="b5" /&gt; &lt;Button android:id="@+id/ql6" android:layout_width="@dimen/qlbutton_width" android:layout_height="@dimen/qlbutton_height" android:layout_marginTop="180dp" android:layout_marginLeft="150dp" android:text="b6" /&gt; &lt;Button android:id="@+id/ql7" android:layout_width="@dimen/qlbutton_width" android:layout_height="@dimen/qlbutton_height" android:layout_marginTop="180dp" android:layout_marginLeft="220dp" android:text="b7" /&gt; &lt;Button android:id="@+id/ql8" android:layout_width="@dimen/qlbutton_width" android:layout_height="@dimen/qlbutton_height" android:layout_marginTop="260dp" android:layout_marginLeft="10dp" android:text="b8" /&gt; &lt;Button android:id="@+id/ql9" android:layout_width="@dimen/qlbutton_width" android:layout_height="@dimen/qlbutton_height" android:layout_marginTop="260dp" android:layout_marginLeft="80dp" android:text="b9" /&gt; &lt;Button android:id="@+id/ql10" android:layout_width="@dimen/qlbutton_width" android:layout_height="@dimen/qlbutton_height" android:layout_marginTop="260dp" android:layout_marginLeft="150dp" android:text="b10" /&gt; &lt;Button android:id="@+id/ql11" android:layout_width="@dimen/qlbutton_width" android:layout_height="@dimen/qlbutton_height" android:layout_marginTop="260dp" android:layout_marginLeft="2dp" android:text="b11" /&gt; &lt;/RelativeLayout&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload