Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to fade edge of TextView in Android?

I am working on Android 3.0. I have a TextView on my layout and I want it to be faded after 8 characters like in the main menu. This Text is located in RelativeLayout.

<TextView android:layout_width="wrap_content"   
android:layout_height="wrap_content"        
android:id="@+id/item_name"         
android:textStyle="bold"        
android:textColor="@color/white"        
android:maxWidth="50dp"         
android:maxLength="8"       
android:layout_below="@+id/item_frame"  
android:layout_alignBottom="@+id/item_view"         
android:layout_centerHorizontal="true" 
android:fadingEdge="horizontal"> 
</TextView>

Does anyone has an idea how to fade the text after few characters?

like image 624
Yaniv Avatar asked Feb 03 '23 16:02

Yaniv


1 Answers

I think you need to combine fadingEdge with ellipsize and singleLine, and even then it will only happen if the text is longer than the control's width.

like image 65
Torp Avatar answered Feb 05 '23 05:02

Torp