Android 如何在ImageView和TextView之间省略TextView?

Android 如何在ImageView和TextView之间省略TextView?,android,android-studio,android-layout,textview,Android,Android Studio,Android Layout,Textview,以下是我的布局: <LinearLayout android:layout_width="match_parent" android:layout_height="65dp" android:layout_marginStart="20dp" android:gravity="center_vertical|start" android:orientation="horizontal"> <ImageView a

以下是我的布局:

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="65dp"
    android:layout_marginStart="20dp"
    android:gravity="center_vertical|start"
    android:orientation="horizontal">

    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginStart="18.9dp"
        android:lineSpacingExtra="64sp"
        android:textColor="#484848"
        android:textSize="16sp"
        tools:text="அனைத்து  அனைத்துஅனைத்து" />

    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginStart="50dp"
        android:lineSpacingExtra="64sp"
        android:text="0"
        android:textAlignment="center"
        android:textColor="@color/red_500"
        android:textSize="14sp" />
</LinearLayout>

除了泰米尔语之外,所有其他语言都运行良好

我需要一个图标在开始,有时它显示在最后通知的数量。所以我需要将
省略设置为中间文本


如何实现这一点?

您可以使用
android:ellipsize
a属性来实现这一点

像这样:

<TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="18.9dp"
                        android:lineSpacingExtra="64sp"
                        android:textColor="#484848"
                        android:textSize="16sp"
                        android:ellipsize="end"
                        android:maxLines="1"
                        tools:text="அனைத்து  அனைத்துஅனைத்து" />


注意:不要忘记使用
android:maxLines
属性来设置文本的行号。

您可以使用
android:ellipize
属性来完成此操作

像这样:

<TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="18.9dp"
                        android:lineSpacingExtra="64sp"
                        android:textColor="#484848"
                        android:textSize="16sp"
                        android:ellipsize="end"
                        android:maxLines="1"
                        tools:text="அனைத்து  அனைத்துஅனைத்து" />

注意:不要忘记使用
android:maxLines
属性设置文本的行号