How to draw glowing text?

NeoTechni

Well-Known Member
Licensed User
Longtime User
I don't want to use a view, just the API to print text at X/Y.

I found some XML to do it with a view:
B4X:
I use this but no effect... xml is: <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Glow" android:textSize="40sp" android:id="@+id/id_tv_GlowText" android:textStyle="bold" android:shadowColor="#0000ff" android:textColor="#0000ff" android:shadowDx="0.0" android:shadowDy="0.0" android:shadowRadius="280"/> also tried 210... same result... – Farhan Apr 17 '11 at 10:22
yup you are right... but little change. set shadowradius = "8"... – Farhan Apr 17 '11 at 15:34
+1 it works..

Or: http://developer.android.com/reference/android/widget/TextView.html#attr_android:shadowColor

Is there a way to get that?
 

vb1992

Well-Known Member
Licensed User
Longtime User
Maybe this as an intent or mini library?


Bitmap alpha = origin.extractAlpha();

BlurMaskFilter blurMaskFilter = new BlurMaskFilter(5, BlurMaskFilter.Blur.OUTER);

Paint paint = new Paint();
paint.setMaskFilter(blurMaskFilter);
paint.setColor(0xffffffff);

Canvas canvas = new Canvas(origin);
canvas.drawBitmap(alpha, 0, 0, paint);

return origin;
 
Upvote 0

vb1992

Well-Known Member
Licensed User
Longtime User
Reflector

I am getting a NoSuchMethodException error, Erel?


B4X:
Dim Label1 as Label

Label1.Text = "GLOWING TEXT"
  

Dim Obj1 As Reflector
Obj1.Target = Label1

Dim args(5) As Object
Dim types(5) As String   

args(0) = Label1
types(0) = "android.widget.TextView"

args(1) = 5
types(1) = "java.lang.float"   

args(2) = 5
types(2) = "java.lang.float"   


args(3) = 5
types(3) = "java.lang.float"   


args(4) = 5
types(4) = "java.lang.int"   

Obj1.RunMethod4("setShadowLayer", args, types)


TextView | Android Developers
B4X:
public void setShadowLayer (float radius, float dx, float dy, int color)

Since: API Level 1
Gives the text a shadow of the specified radius and color, the specified distance from its normal position.
Related XML Attributes

android:shadowColor
android:shadowDx
android:shadowDy
android:shadowRadius
 
Last edited:
Upvote 0

NeoTechni

Well-Known Member
Licensed User
Longtime User
I dont want to use a view though, would that work on the canvas itself? And be reversible?
 
Upvote 0

vb1992

Well-Known Member
Licensed User
Longtime User
Thanks Erel (And Andrew (Reflector Library!))

If anyone wants to create a Glow, Blur, DropShadow effect on Text, here it is

B4X:
                  Dim Obj1 As Reflector
                  Obj1.Target = Label1
               
                  args(0) = 3  'Radius of the Blur/GlowDropShadow
                  types(0) = "java.lang.float"   
                  
                  
                  args(1) = 3
                  types(1) = "java.lang.float"   
                  
                  
                  args(2) = 3
                  types(2) = "java.lang.float"   
                  
                  
                  args(3) = Colors.ARGB(255,0,0,255) ' Color of th Glow/Blur
                  types(3) = "java.lang.int"   
                  
                  Obj1.RunMethod4("setShadowLayer", args, types)
 
Upvote 0

vb1992

Well-Known Member
Licensed User
Longtime User
I am trying to get this to work on creating a glow/blur
around the edges of an Image now and got this error:

java.lang.NoSuchMethodException: BlurMaskFilter [float, class android.graphics.BlurMaskFilter$Blur]




B4X:
Imageview1.Bitmap = LoadBitmap(File.DirAssets,"17.jpg")
   
   Dim BitMap1 As Bitmap
   Bitmap1.InitializeMutable(200,200)
 
        CC.Initialize2(Bitmap1)
 
      
   
   Dim obj1As Reflector

   obj1.Target = CC
    

   obj1.RunMethod3("BlurMaskFilter",5,"java.lang.float", "NORMAL", "android.graphics.BlurMaskFilter$Blur")

public BlurMaskFilter (float radius, BlurMaskFilter.Blur style)

Since: API Level 1
Create a blur maskfilter.
Parameters

radius The radius to extend the blur from the original mask. Must be > 0.
style The Blur to use
Returns

The new blur maskfilter



BlurMaskFilter | Android Developers


Example of what this will achieve....
 

Attachments

  • highlight.jpg
    highlight.jpg
    6.3 KB · Views: 413
Upvote 0

vb1992

Well-Known Member
Licensed User
Longtime User
Upvote 0
Top