Note that there are some explanatory texts on larger screens.

plurals
  1. POCan I use layout_weight to position a RelativeLayout?
    text
    copied!<p>I've been trying all day to get this to work and i think that I can use <code>RelativeLayout</code> </p> <pre><code>android:layout_weight="0.3" </code></pre> <p>to place three buttons on the right side of the screen, not centered but 30% down from the top. </p> <p>Is this possible and if so how do I do it?</p> <p>The following is my XML that shows three buttons underneath each other but in top right position:</p> <pre><code> &lt;/RelativeLayout&gt; &lt;LinearLayout android:id="@+id/rightRelativeLayout" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentRight="true" android:layout_weight="1" android:orientation="vertical" &gt; &lt;ImageButton android:id="@+id/btn_A" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1" android:text="A" android:src="@drawable/drawer_1" android:background="@android:color/transparent" /&gt; &lt;ImageButton android:id="@+id/btn_B" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="10dp" android:layout_weight="1" android:text="B" android:src="@drawable/drawer_1" android:background="@android:color/transparent" android:layout_below="@+id/btn_A" /&gt; &lt;ImageButton android:id="@+id/btn_C" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1" android:layout_marginTop="10dp" android:text="C" android:src="@drawable/drawer_1" android:background="@android:color/transparent" android:layout_below="@+id/btn_B" /&gt; &lt;/LinearLayout&gt; </code></pre> <p>[UPDATE] Added final working version for people who need it</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;RelativeLayout android:id="@+id/RelativeLayout1" android:layout_width="fill_parent" android:layout_height="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical"&gt; &lt;Gallery xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/examplegallery" android:layout_width="fill_parent" android:layout_height="wrap_content" /&gt; &lt;RelativeLayout android:id="@+id/InnerRelativeLayout" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_alignParentBottom="true" &gt; &lt;Button android:id="@+id/btn_newpen_drawtext" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Pen" /&gt; &lt;EditText android:id="@+id/etx_addtext_drawtext" android:layout_width="fill_parent" android:layout_toLeftOf="@+id/btn_delete_pen" android:layout_toRightOf="@+id/btn_newpen_drawtext" android:layout_height="wrap_content" android:singleLine="true" android:text="" /&gt; &lt;Button android:id="@+id/btn_delete_pen" android:layout_toLeftOf="@+id/btn_save_drawtext" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Del" /&gt; &lt;Button android:id="@+id/btn_save_drawtext" android:layout_alignParentRight="true" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="save" /&gt; &lt;/RelativeLayout&gt; &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/rightLinerLayoutL0" android:layout_width="wrap_content" android:layout_height="fill_parent" android:layout_toRightOf="@+id/RelativeLayout1" android:weightSum="1.0" android:layout_alignParentRight="true" android:orientation="vertical" &gt; &lt;LinearLayout android:layout_height="0dp" android:id="@+id/rightLinerLayoutL1" android:layout_weight="0.15" android:layout_width="0dp"&gt; &lt;/LinearLayout&gt; &lt;LinearLayout android:layout_height="0dp" android:orientation="vertical" android:id="@+id/rightLinerLayoutL2" android:layout_weight="0.85" android:layout_width="wrap_content"&gt; &lt;ImageButton android:text="Button_A" android:background="@android:color/transparent" android:layout_height="wrap_content" android:id="@+id/btn_A" android:layout_width="wrap_content" android:layout_gravity="right" android:src="@drawable/drawer" android:onClick="btnAListener"&gt; &lt;/ImageButton&gt; &lt;ImageButton android:text="Button_B" android:background="@android:color/transparent" android:layout_height="wrap_content" android:layout_marginTop="10dp" android:id="@+id/btn_B" android:layout_width="wrap_content" android:layout_gravity="right" android:src="@drawable/drawer" android:onClick="btnBListener"&gt; &lt;/ImageButton&gt; &lt;ImageButton android:text="Button_C" android:background="@android:color/transparent" android:layout_height="wrap_content" android:layout_marginTop="10dp" android:id="@+id/btn_C" android:layout_width="wrap_content" android:layout_gravity="right" android:src="@drawable/drawer" android:onClick="btnCListener"&gt; &lt;/ImageButton&gt; &lt;/LinearLayout&gt; &lt;/LinearLayout &gt; &lt;/RelativeLayout&gt; </code></pre>
 

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