Question

I need to place two EditText side by side, the left one can be multiline, but the right one has to be just one line. I've used a table layout with just one row but I have the following problem, the second column should have just the enough room to show the one single line text but not more. How can I achive that? Thank you very much

<TableLayout 
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal">

<TableRow
android:background="#87F1FF"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >

    <TextView
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    android:layout_weight="1"
    android:maxLines="3"
    android:text="this can take more than a line"
    android:textColor="@android:color/black"
    android:textSize="40sp" />

    <TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_weight="1"
    android:background="#454545"
    android:maxLines="1"
    android:text="May 25 - 10:00 pm"
    android:textColor="@android:color/black"
    android:textSize="20sp" />

</TableRow>
</TableLayout>

Sample

Was it helpful?

Solution

Make second TextView without android:layout_weight="1"

OTHER TIPS

Just change in your 2nd TextView:

android:layout_width="0dp"

Instead of

android:layout_width="wrap_content"
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top