0

I have seen a few questions about the same problem, "Ellipsize is not working". None of the solutions work for me. Actually, the textview is setted like this:

As seen in Ellipsize not working for textView inside custom listView.

<com.neopixl.pixlui.components.textview.TextView
    android:id="@+id/wifispot_info_address"
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:layout_marginLeft="15dp"
    android:layout_weight="0.5"
    android:gravity="center_vertical"
    android:text="@string/default_string"
    android:textColor="@color/black"
    android:textSize="16sp"
    pixlui:typeface="NeutraText-Book.otf"
    android:ellipsize="end"
    android:scrollHorizontally="true"
    android:singleLine="true"/>

Also I tried to set the property in the fragment code, as seen here Ellipsize is not working:

spotAddress = (TextView) view.findViewById(R.id.wifispot_info_address);
spotAddress.setEllipsize(TextUtils.TruncateAt.END);

The better results show the "address" cutted without the ellipsize and the rest is "displayed" in another line.

Starting with this xml, what can I do?

<com.neopixl.pixlui.components.textview.TextView
    android:id="@+id/wifispot_info_address"
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:layout_marginLeft="15dp"
    android:layout_weight="0.5"
    android:gravity="center_vertical"
    android:text="@string/default_string"
    android:textColor="@color/black"
    android:textSize="16sp"
    pixlui:typeface="NeutraText-Book.otf"
    android:ellipsize="end"
    android:scrollHorizontally="true"
    android:singleLine="true"/>
Community
  • 1
  • 1
Javier Sivianes
  • 784
  • 1
  • 9
  • 25

1 Answers1

0

You can add android:maxLines="1"

Makes the TextView be at most this many lines tall. When used on an editable text, the inputType attribute's value must be combined with the textMultiLine flag for the maxLines attribute to apply.

<com.neopixl.pixlui.components.textview.TextView
android:id="@+id/wifispot_info_address"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginLeft="15dp"
android:layout_weight="0.5"
android:gravity="center_vertical"
android:text="@string/default_string"
android:textColor="@color/black"
android:textSize="16sp"
pixlui:typeface="NeutraText-Book.otf"
android:ellipsize="end"
android:scrollHorizontally="true"
android:singleLine="true"
android:maxLines="1"/>
IntelliJ Amiya
  • 74,896
  • 15
  • 165
  • 198