Note that there are some explanatory texts on larger screens.

plurals
  1. POLayout out elements within a RelativeLayout
    primarykey
    data
    text
    <p>I'm having a very difficult time figuring out how to lay out this element. Here's what I want to do (apologies for my MS Paint skills):</p> <p><img src="https://i.stack.imgur.com/qK0ln.png" alt="Layout"></p> <p>Here, the gray box is supposed to be an ImageView. The red lines here are just to make the sections more clear - not worried abot how to draw them. The features that I'm trying to get are:</p> <ol> <li><p>The ImageView is aligned relative to the topmost red line, and to the left edge of the green box.</p></li> <li><p>The "TEXT" is to the right of the image, and centered vertically in its section.</p></li> </ol> <p>Without the ImageView, this is pretty straightforward - just a LinearLayout with three TextViews and some padding. I've tried doing this wit a RelativeLayout, but I'm unsure of how to center Text within the box without relying on guessing at the padding/margin.</p> <p>I figured out how to get the box hanging over. I created my RelativeLayout</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="200dp" android:layout_height="200dp" android:layout_marginTop="20dp" android:background="#3AF"&gt; &lt;LinearLayout android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_alignParentLeft="true" android:layout_alignParentTop="true" android:layout_marginTop="20dp" android:background="#AAA"&gt; &lt;TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="New Text" android:padding="10dp" android:id="@+id/textView"/&gt; &lt;TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="New Text" android:padding="10dp" android:id="@+id/textView1"/&gt; &lt;TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="New Text" android:padding="10dp" android:id="@+id/textView2"/&gt; &lt;/LinearLayout&gt; &lt;ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="10dp" android:src="@drawable/ic_launcher" android:id="@+id/imageView" android:layout_alignParentLeft="true" android:layout_alignParentTop="true"/&gt; &lt;/RelativeLayout&gt; </code></pre> <p>But what I can't figure out is how to align the topmost TextView to the right of the ImageView. (Note - this is just my attempt. The layout type/style is entirely flexible at this point).</p> <p>Here's a screenshot of how it looks in the designer:</p> <p><img src="https://i.stack.imgur.com/M0R7q.png" alt="Screenshot"></p> <p>Any ideas?</p>
    singulars
    1. This table or related slice is empty.
    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.
 

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