Android Question How to add solid outline color for text?

Widget

Well-Known Member
Licensed User
Longtime User
The shadow can be added with this code:
B4X:
Sub SetTextShadow(lbl As Label)
   Dim jo As JavaObject = lbl
   Dim radius = 2dip, dx = 0dip, dy = 0dip As Float
   jo.RunMethod("setShadowLayer", Array(radius, dx, dy, Colors.Yellow))
End Sub

This is an improvement. (See image)

B4X:
Sub Activity_Create(FirstTime As Boolean)'Do not forget to load the layout file created with the visual designer. For example:'Activity.LoadLayout("Layout1")Activity.Color = Colors.Black
 Label1.Initialize("")
 Label1.Text = "Testing"
 Label1.TextSize = 100
 Label1.TextColor = Colors.BlueActivity.AddView(Label1, 20Dip, 20Dip, 500dip, 500dip)
 Private jo AsJavaObject = Label1' Private Radius = 4dip, dx=0dip, dy=0dip As FloatPrivate Radius = 10dip, dx=0dip, dy=0dipAs Float
 jo.RunMethod("setShadowLayer", Array(Radius, dx,dy, Colors.Yellow))End Sub

But there are 2 problems.
  1. Doesn't "setShadowLayer" require hardware acceleration to be turned on? And it is turned on for targetSDK >= 14 but not for Android 6?
  2. The shadow it produces uses a blur, which is fine on large text but is barely noticeable on smaller text. Is there a way to eliminate the blur so it works better on smaller text?
TIA
 

Attachments

  • TextShadow.png
    TextShadow.png
    19.9 KB · Views: 332

Erel

B4X founder
Staff member
Licensed User
Longtime User
Upvote 0
Top