This layout seems simple but I can't find any way to do this solely in xml using LinearLayout
or any other layout without changing properties dynamically. Here is what I want, if text is short then layout should be totally wrapped as shown in figure:
But in case TextView
contains longer text then it should be expanded but it must leave space for Button
like this:
After experimenting a lot of layout, the best that I can do is to use TableLayout
with shrinkColumns
<TableLayout 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:shrinkColumns="0" >
<TableRow>
<TextView
android:id="@+id/text"
android:ellipsize="end"
android:singleLine="true"
android:text="This is a very long text and it cannot be displayed wholly" />
<Button
android:id="@+id/button"
android:text="Button" />
</TableRow>
</TableLayout>