I am trying to get a line of text that will be something like
foofoofoo - barbarbar
but I want it to be an ellipse of foo and bar, if it does not fit on one line. those. I try to cut them.
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TextView android:id="@+id/text_1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:maxWidth="0dip"
android:layout_weight="1"
android:textColor="#ffffff"
android:singleLine="true"
android:ellipsize="true"
android:text="foofoofoofoo" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#ffffff"
android:text=" - " />
<TextView
android:id="@+id/text_2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:maxWidth="0dip"
android:layout_weight="1"
android:textColor="#ffffff"
android:singleLine="true"
android:ellipsize="true"
android:text="barbarbarbar" />
</LinearLayout>
Follow me, it works partially.
Setting TextView layout_widthon 0dipand layout_weighton 1means that they will occupy 50% of the available space each.
Setting it singleLineto trueand ellipsizeto truemeans that they will look like foofoo ... if the text is larger than the container.
So my result (if the text is longer) should be
foofoo .. - barbar ..
What it is! So it works.
, ,, TextView (id: text_1) , 50%, layout_width="0dip" layout_weight="1" , wrap_content. :
foo - barbar..
foo - barbarbar
layout_width="wrap_content" android:maxWidth="0dip", ! , , wrap_content 50%!
, android:adjustViewBounds="true" maxWidth, .