There is a TextView that displays various small texts, so the font is large and the android attribute is set: singleLine = "true". But sometimes TextView shows texts a bit longer, and at the end of the text breaks off and put ellipsis (due to singleLine). Is it possible to somehow make the text appear all the same completely, but in a smaller font? Whether programmatically it is possible to somehow find out whether the text got completely, or is hidden behind ellipsis?

just in case my textview:

<TextView android:id="@+id/mytw" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:layout_marginLeft="20dp" android:layout_marginRight="20dp" android:gravity="center_horizontal" android:singleLine="true" android:text="" android:textAppearance="?android:attr/textAppearanceLarge" /> 

3 answers 3

Or make scrolling animation (marquee effect) of long text in standard ways:

 <TextView android:singleLine="true" android:ellipsize="marquee" android:marqueeRepeatLimit ="marquee_forever" android:scrollHorizontally="true" android:focusable="true" android:focusableInTouchMode="true" 

Well, or reduce the font size for the text.

    Look at what the maximum length gets into TextView and just do a check, if it is less then it is not me, otherwise change it .. this is of course a rude method ..

    • On different devices in different ways, somewhere one length fits, somewhere else ... Although you can write several values ​​that would be substituted for different screens, but I still hoped that there is a more elegant way. - Tuhlom

    Install textsize in sp , well, probably try the @ sulo . Although it is really some kind of crutch.