如何限制TextView的大小?

问题描述 投票:1回答:1

我想有一个包含两个文本视图的框,一个标题和一个文本,长度可以长也可以不长。像这样:

<< img src =“ https://image.soinside.com/eyJ1cmwiOiAiaHR0cHM6Ly9pLnN0YWNrLmltZ3VyLmNvbS9Gb0hYYS5wbmcifQ==” alt =“在此处输入链接描述”>

当前,我所拥有的是:如果文本太大,则将其移到标题上方。该框可以具有所需的任何布局(相对,约束...)...

有人知道该怎么做吗?

android xml android-layout layout android-xml
1个回答
0
投票
<LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" tools:text="title"/> <TextView android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:gravity="end" tools:text="some very very very very very very very very long text"/> </LinearLayout>
© www.soinside.com 2019 - 2024. All rights reserved.