android – How to ellipsize a TextView in between an ImageView and a TextView?-ThrowExceptions

Exception or error:

Here is my layout:

<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>

All other languages are working fine, except tamil language is very big.

enter image description here

I need an icon at beginning and sometimes it show number of notifications at end. So I need to set ellipsize to text on middle.

How to achieve this?

How to solve:

you can use android:ellipsize atrribute to do that.

like this :

<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="அனைத்து  அனைத்துஅனைத்து" />

note: don’t forget to use android:maxLines attribute to set the line number of your text.

Leave a Reply

Your email address will not be published. Required fields are marked *