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:
Android-FadingEdgeLayoutA versatile layout that fades its edges regardless of child view type.
You are applying to your TextView a compound Drawable on the right.. to make the three dots appear in this scenario, you have to apply a android:drawablePadding="{something}dp" attribute to the TextView as well. Hope it helps!
When you have a LinearLayout view, you can center the TextView widget by setting the layout_width and layout_height attributes of the TextView to match_parent and the gravity attribute to center . You can also center multiple TextView widgets by using the layout_weight attribute.
A TextView displays text to the user and optionally allows them to edit it. A TextView is a complete text editor, however the basic class is configured to not allow editing.
According to https://developer.android.com/reference/android/R.attr.html#fadingEdge 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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With