我有这样的(部分)布局:如何“锁定”的宽度在的TableRow
<TableRow
android:id="@+id/trLocation"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/location"/>
<TextView android:layout_width="wrap_content"
android:textSize="50dp"
android:layout_height="wrap_content"
android:text="1234"
android:id="@+id/tvLocation"
android:layout_weight="1"
/>
</TableRow>
现在,当我做出tvLovation
数据过长,它将“推动” textView3
小,直到文本内容甚至被剪切,或者如果maxLines
未设置,则流向下一行。
如何确保第一列的宽度永远不会比我最长的文本更小?
将ellipsize
添加到tvLocation
不起作用。
谢谢,这似乎这样的伎俩意见水平对齐。显然,'layout_width'比'layout_weight'有更高的偏好?你是否可以参考有关这方面的文档? –
在LinearLayout的源代码中读取measureHorizontal()或measureVertical()方法。 你会明白的。 – Deng