androidtextviewandroid-xmlglow

How to make text glow programmatically (via code, not xml) in android?


I want to know how to make my text glow in android, I know how to do via xml with some attributes, like this:

android:shadowColor="#6A8B00"
android:shadowDx="3"
android:shadowDy="3"
android:shadowRadius="10"
android:text="@string/glowText"
android:textColor="#E15529"
android:textSize="30sp"

but I want to do via code, then I can control better and make glow more or less in different situations. Maybe has something like view.setGlow?


Solution

  • You can use setShadowLayer (float radius, float dx, float dy, int color) on your textview. For example:

    textView.setShadowLayer(30, 0, 0, Color.RED);
    

    Found in the TextView documentation