繁体   English   中英

Android:两列,一列包含换行文字,另一行

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

我需要并排放置两个EditText,左边的可以是多行,但是右边的只能是一行。 我使用的表格布局只有一行,但是我遇到了以下问题,第二列应该有足够的空间来显示单行文本,但不能显示更多。 我该如何实现? 非常感谢你

<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"

只需更改第二个TextView:

android:layout_width="0dp"

代替

android:layout_width="wrap_content"

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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