我有这个布局:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="left">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Some text" />
</LinearLayout>
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView"/>
</LinearLayout>
但是,如果在第一个文本视图(在 LinearLayout 中)有很多文本,第二个文本视图就会离开屏幕。这可以通过将 android:layout_weigh="1" 设置为线性布局来解决。但是在这种情况下,线性布局将填充所有空间,并且我需要线性布局在短文本中填充最小空间,并且在线性布局中有很多文本时不隐藏第二个文本视图。