Refering agradient to textview regard as normal action can be achieved in android ,
as below :
android:background="@drawable/gredient"
and gradient XML will be as below code :
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient android:startColor="#B22222" android:centerColor="#000000"
android:endColor="#B22222" android:angle="0" />
<corners android:radius="15dp" />
</shape>
what im asking about is there is away in android to apply multiple gradients to single textview consisting of may paragraphs , so each paragraph will has different gradient .
any advice will be appreciated ,
thanks
You might want to consider using a
WebViewinstead ofTextView(if you need more advanced formatting), but if you want to stick to a TextView,LineBackgroundSpanis your friend 🙂Although there might be some better solution (most likely involving a custom
Layout-derived class), here’s some sample code that should do what you want just by implementing a specialLineBackgroundSpaninterface: