Note that there are some explanatory texts on larger screens.

plurals
  1. POHow can I prevent a textfield from overflowing adjacent text fields on android?
    primarykey
    data
    text
    <p>I've got a problem with an android layout.</p> <p>I've got one line with three TextViews: a job title, an age and a date. I want the date to be aligned to the right and the job title to the left. The age should be aligned right to the job title.</p> <p>The problem is that the job title can become very long. I want that it does not overlap the other to views but gets truncated automatically instead. The other two text views should always be visible.</p> <p>Any ideas how I can achieve this? I want my layout to span the whole width of the screen and thus don't want to work with absolute widths.</p> <p>My layout looks as follows:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="horizontal" android:layout_width="match_parent" android:layout_height="match_parent" &gt; &lt;TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Softwaredeveloper and some more very long job titles so that the text overflows" android:id="@+id/occupation" android:layout_gravity="left|center_vertical" android:padding="5dp" android:layout_alignParentLeft="true" android:layout_alignParentTop="true" android:singleLine="true" android:ellipsize="end"/&gt; &lt;TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="(32)" android:id="@+id/age" android:layout_gravity="left|center_vertical" android:padding="5dp" android:layout_alignParentLeft="false" android:layout_alignParentTop="true" android:layout_toRightOf="@+id/occupation" android:singleLine="true"/&gt; &lt;TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="01.02.2013" android:id="@+id/date" android:layout_alignParentLeft="false" android:layout_alignParentTop="true" android:layout_alignParentRight="true" android:singleLine="true" android:padding="5dp"/&gt; &lt;/RelativeLayout&gt; </code></pre> <p>And this is what I get:</p> <p><img src="https://i.stack.imgur.com/JAZ7F.png" alt="enter image description here"></p>
    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.
 

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