Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Have you already done something with relative layouts?</p> <p>This is how I would solve this. You give every view an id by </p> <pre><code>android:id = "@+id/whateveryouwanttonameit" </code></pre> <p>and then you can align other views by reffering to this ids.</p> <p>For example:</p> <pre><code>&lt;ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:id="@+id/newGameButton" android:text="@string/newGameButton" android:background="@drawable/newgame" android:contentDescription="@string/feld"/&gt; &lt;ImageView android:layout_alignLeft="@id/newGameButton" android:layout_width="50dp" android:layout_height="50dp" android:layout_above="@id/newGameButton" android:src="@drawable/x" android:id="@+id/sp2" android:contentDescription="@string/feld"/&gt; </code></pre> <p>in this example the ImageViews Left edge gets aligned with the left edge of the ImageButton by using: </p> <pre><code>android:layout_alignLeft="@id/newGameButton" </code></pre> <p>It is also exactly above the newGameButton without any space between by adding </p> <pre><code>android:align_above="@id/newGameButton" </code></pre> <p>This way you can build your whole activity layout.</p> <p>So here is the example: </p> <pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:background="#FFFFFF" &gt; &lt;View android:layout_width="fill_parent" android:layout_height="15dp" android:background="#FF0000" android:layout_above="@id/scroller" /&gt; &lt;ScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/scroller" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerInParent="true" android:fillViewport="true" android:background="#000000"&gt; &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="#00FF00" &gt; &lt;ImageView android:id="@+id/btn1_news_feed" android:layout_width="280dp" android:layout_height="50dp" android:layout_gravity="center_horizontal" android:layout_margin="2dp" android:background="#000000" android:contentDescription="@string/app_name" /&gt; &lt;ImageView android:id="@+id/btn2_news_feed" android:layout_width="280dp" android:layout_height="50dp" android:layout_gravity="center_horizontal" android:layout_margin="2dp" android:layout_below="@id/btn1_news_feed" android:background="#000000" android:contentDescription="@string/app_name"/&gt; &lt;ImageView android:id="@+id/btn3_news_feed" android:layout_width="280dp" android:layout_height="50dp" android:layout_gravity="center_horizontal" android:layout_margin="2dp" android:layout_below="@id/btn2_news_feed" android:background="#000000" android:contentDescription="@string/app_name" /&gt; &lt;ImageView android:id="@+id/btn4_news_feed" android:layout_width="280dp" android:layout_height="50dp" android:layout_gravity="center_horizontal" android:layout_margin="2dp" android:layout_below="@id/btn3_news_feed" android:background="#000000" android:contentDescription="@string/app_name" /&gt; &lt;ImageView android:id="@+id/btn5_news_feed" android:layout_width="280dp" android:layout_height="50dp" android:layout_gravity="center_horizontal" android:layout_margin="2dp" android:layout_below="@id/btn4_news_feed" android:background="#000000" android:contentDescription="@string/app_name" /&gt; &lt;/RelativeLayout&gt; &lt;/ScrollView&gt; &lt;/RelativeLayout&gt; </code></pre> <p>gives me this layout:</p> <p><img src="https://i.stack.imgur.com/bU9Yh.gif" alt="layout"></p> <p>i kept the margin attribute and made the background of the scrollview in green.</p> <p>With the below attribute I made the layout.</p> <p>And just for showing you that there is no space in between to elements if you not define it I added a red View Element without a margin attribute.</p> <p>I havent done the whole layout for you but just copied some of it to show how you can do it with a RelativeLayout. I hope this works out for you ;)</p>
 

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