5

I have a list, each row in the list has text. Some of the text extends beyond the edge of the screen. I have no problem making it truncate the text and show ellipses. I have no problem to 'fade the edge of the text' however, the fade occurs at the edge of every text, not just the ones the are too large for the textview.

I have searched and searched and can't find a way to, essentially, do exactly what the ellipses do, but, instead of ellipses, fade the edge of the text only if it is going off the edge of the screen. Can anyone please help? Right now, my text view contains:

android:fadingEdge="horizontal" 
android:inputType="text"
android:maxLines="1"

I have tried many other things to no avail.

TylerH
  • 20,799
  • 66
  • 75
  • 101
fatfreddyscat
  • 835
  • 3
  • 8
  • 26
  • p.s. just realized that, when I use those 3 fields (horizontal, text, 1), I can't actually select a list item for whatever reason. just thought I'd point this out. – fatfreddyscat Sep 20 '11 at 18:04

2 Answers2

4

To enable marquee and simulateouly not affecting the list Selections Just use following:

In the code just use two methods on that text View.

textViewObj.setSelected(true);
textViewObj.setEllipsize(TextUtils.TruncateAt.MARQUEE);
Haspemulator
  • 11,050
  • 9
  • 49
  • 76
Arpit Garg
  • 8,476
  • 6
  • 34
  • 59
  • I don't have access to the text view in code but, I set the ellipsize in the layout xml file and it worked. Thanks!!! (I thought that I had done it before but, for some reason, I just assumed that setting 'ellipsize' meant that I would have ellipses but, apparently not :-) Thanks again! – fatfreddyscat Sep 20 '11 at 20:25
  • p.s. unfortunately I don't have enough reputation to "vote up" or accept your response so, will depend on someone else to do it. – fatfreddyscat Sep 20 '11 at 20:27
  • yeah... only have '13' reputation but, says I need 15 to vote up. I don't know how to gain reputation, heh. – fatfreddyscat Sep 21 '11 at 23:52
2

The specific method call to enable the horizontal edge fade (on the right-hand side) is

setHorizontalFadingEdgeEnabled(true)

Here is an example from the constructor in my class ScrollTextView, which extends TextView:

public ScrollTextView(Context context, AttributeSet attrs) {
    this(context, attrs, android.R.attr.textViewStyle);
    setHorizontalFadingEdgeEnabled(true);
}
Ari Lacenski
  • 631
  • 12
  • 18