Android 布局2个文本视图,带有不同的;“优先事项”;

Android 布局2个文本视图,带有不同的;“优先事项”;,android,textview,alignment,android-linearlayout,Android,Textview,Alignment,Android Linearlayout,我有这个 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="horizontal" android:layout_width="match_parent" android:layout_height="match_parent"> <TextView

我有这个

<LinearLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:orientation="horizontal"
        android:layout_width="match_parent"
        android:layout_height="match_parent">
    <TextView
            android:id="@+id/text1"
            android:layout_width="fill_parent"
            android:layout_height="match_parent"
            android:ellipsize="end" />

    <TextView
            android:id="@+id/text2"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:gravity="right"
            android:maxLines="1" />
</LinearLayout>

但我希望text2比text1具有“更高的优先级”

意味着如果屏幕不能同时满足这两个条件,我需要有这样的行为:

Text2必须始终在一行中完全显示,除非它超过屏幕的80%,在这种情况下,请使用“…”

Text1使用Text2剩下的任何空间,可以使用多行,如果不合适,应该在末尾使用“…”


使用LinearLayout可以这样做吗?或者我应该使用不同的容器来代替?

您最好使用片段,请参阅本教程:


它们完全可以满足您的需求。

您最好使用片段,请参阅本教程:


它们完全可以满足您的需求。

考虑使用
ConstraintLayout


考虑使用
ConstraintLayout


我不知道android提供的任何布局是否可行。您可能需要编写自定义视图或以编程方式管理此视图…您是否尝试过使用
layout\u-weight
?@xFighter我只喜欢使用xml@yogur我怀疑它是否有可能,我不知道android提供的任何布局是否有可能。您可能需要编写自定义视图或以编程方式管理此视图…您是否尝试过使用
layout\u-weight
?@xFighter我只喜欢使用xml@yogur我怀疑这是可能的这看起来很有希望