Code to create a nice halo animation:
Code is compatible with B4A, B4J and B4i.
Usage example:
Requires XUI library v1.25+
Code is compatible with B4A, B4J and B4i.
B4X:
Sub CreateHaloEffect (Parent As B4XView, x As Int, y As Int, clr As Int)
Dim cvs As B4XCanvas
Dim p As B4XView = xui.CreatePanel("")
Dim radius As Int = 150dip
p.SetLayoutAnimated(0, 0, 0, radius * 2, radius * 2)
cvs.Initialize(p)
cvs.DrawCircle(cvs.TargetRect.CenterX, cvs.TargetRect.CenterY, cvs.TargetRect.Width / 2, clr, True, 0)
Dim bmp As B4XBitmap = cvs.CreateBitmap
For i = 1 To 5
CreateHaloEffectHelper(Parent,bmp, x, y, clr, radius)
Sleep(800)
Next
End Sub
Sub CreateHaloEffectHelper (Parent As B4XView,bmp As B4XBitmap, x As Int, y As Int, clr As Int, radius As Int)
Dim iv As ImageView
iv.Initialize("")
Dim p As B4XView = iv
p.SetBitmap(bmp)
Parent.AddView(p, x, y, 0, 0)
Dim duration As Int = 3000
p.SetLayoutAnimated(duration, x - radius, y - radius, 2 * radius, 2 * radius)
p.SetVisibleAnimated(duration, False)
Sleep(duration)
p.RemoveViewFromParent
End Sub
Usage example:
B4X:
Sub Activity_Touch (Action As Int, X As Float, Y As Float)
If Action = Activity.ACTION_DOWN Then
CreateHaloEffect(Activity, X, Y, xui.Color_Red)
End If
End Sub
Requires XUI library v1.25+
Last edited: