EllipSize-ing not working, is the TextView "too dynamic"?

112 Views Asked by At
    <item name="android:ellipsize">middle</item>
    <item name="android:maxLines">2</item>

I've tried removing attrs. one at a time, but ellipSize seem to not work under any circumstance.

This is how it looks.

enter image description here

Where the complete word is: "Element # 1 ASDASDASDASDASDASDASDASD"

android:text='@{element.element_title + " ASDASDASDASDASDASDASDASD"}'

It seems to me that one of the main issues is that too many dimensions are calculated dynamically and it is choosing to perform actions/ execute attributes in the wrong order.

These are the main and relevant attrs that are working properly:

    <item name="android:maxLines">2</item>
    <item name="autoSizeTextType">uniform</item>
    <item name="autoSizeMaxTextSize">@dimen/text_small</item>
    <item name="autoSizeMinTextSize">@dimen/text_small_small</item>

To my surprise the combo of "maxLines" with "autoSizeTextType" works pretty fine...

Now, IF... I remove these 3 lines:

<item name="autoSizeTextType">uniform</item>
<item name="autoSizeMaxTextSize">@dimen/text_small</item>
<item name="autoSizeMinTextSize">@dimen/text_small_small</item>

... there is a change, but not for the better:

enter image description here

These are my most direct attributes:

In styles.xml:

<style name="small_frame_text_small_bold_autoSize" parent="small_frame_padding" >
        <item name="android:fontFamily">@font/lekton_code_italic</item>
        <item name="android:textStyle">bold</item>
        <item name="android:textSize">@dimen/text_small</item>
        <item name="android:textColor">@color/material_on_background_emphasis_high_type</item>
        <item name="android:ellipsize">middle</item>
        <item name="android:maxLines">2</item>
        <item name="autoSizeTextType">uniform</item>
        <item name="autoSizeMaxTextSize">@dimen/text_small</item>
        <item name="autoSizeMinTextSize">@dimen/text_small_small</item>
    </style>

Now the implementation of the style inside the itemBinding xml: list_item.xml

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal"
            android:divider="?attr/dividerVertical"
            android:showDividers="middle"
            android:gravity="center_horizontal|bottom"
            >

            <androidx.appcompat.widget.AppCompatTextView
                android:id="@+id/element_title"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:text='@{element.element_title + " ASDASDASDASDASDASDASDASD"}'


                style="@style/small_frame_text_small_bold_autoSize"
                android:layout_weight="1.2"
                tools:text="Title"
                android:letterSpacing="0.06"
                android:gravity="center_horizontal|bottom"
                />
0

There are 0 best solutions below