I have some general programming knowledge, but I am new to android developing, and I have started with RecyclerView and I have used cardview too. But in some cases the title there is too long and I just want to add a fading edge.

I have searched in here but I couldn't find anything. So I tried it myself, but I couldn't get it working. I have used it outside the RecyclerView too, but still the same result.

The code I am using.

<TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:textAppearance="?android:attr/textAppearanceLarge" android:text="Hello World" android:id="@+id/textView" android:layout_alignParentTop="true" android:layout_centerHorizontal="true" android:textSize="25sp" android:textStyle="bold" android:fadingEdge="horizontal" <!-- I think those 2 lines should do it, android:fadingEdgeLength="40dp"/> 

I want to make the fading TextView as in this picture from Play Store:

picture

3 Answers

According to android:fadingEdge is deprecated.

It should work with requiresFadingEdge="horizontal" and android:ellipsize="none" :

android:requiresFadingEdge="horizontal" android:fadingEdgeLength="40dp" android:ellipsize="none" 

And I would recommend to use something like android:layout_width="match_parent" or android:layout_width="100dp" if you like the text to be faded.

4

In my case, @Эвансгелист Evansgelist's answer worked perfectly, although the fading was a little too subtle (for that particular project).

In the end, I had to add android:singleLine="true" to @gus27's answer to make it work and get the effect I wanted:

android:requiresFadingEdge="horizontal" android:fadingEdgeLength="40dp" android:ellipsize="none" android:singleLine="true" 

android 6.0.1

This code works

android:ellipsize="marquee" android:marqueeRepeatLimit="0" android:singleLine="true" 

and don't forget

textView.setSelected(true); 

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy