Android - 使用右对齐视图进行布局椭圆化

Chr*_*len 6 android

当Text1变长时,我怎样才能实现这一目标?

| [Text1] [Text2] _ __ _ __ _ __ _ ___ |

| [Text1 Text1 Text1] [Text2] _ ___ |

| [Text1 Text1 Text1 Tex ...] [Text2] |

Text2应该始终位于Text1的右侧,但是当Text1太大时,它会被椭化并且Text2是右对齐的.

小智 1

我有一个场景,我需要这样(与OP非常相似)

[[TextView1][Icon]_______[TextView2]]

[[TextView1 long..][Icon][TextView2]]

因此,TextView1可以具有任意长度,如果无法再容纳,则应将其椭圆化,但 应该Icon就在它旁边,并且TextView2应该始终右对齐

<LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal">

            <FrameLayout
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="1">

                <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:layout_weight="1"
                        android:singleLine="true"
                        android:ellipsize="end"
                        .... />

                    <ImageView
                        android:id="@+id/Icon"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        .... />

                </LinearLayout>

            </FrameLayout>

            <TextView
                android:id="@+id/TextView2"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                .... />
        </LinearLayout>
Run Code Online (Sandbox Code Playgroud)