简体   繁体   中英

Android: Two columns, one with wrapped text and other single line

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>

样品

使第二个TextView没有android:layout_weight="1"

Just change in your 2nd TextView:

android:layout_width="0dp"

Instead of

android:layout_width="wrap_content"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM