Android Question Simple Halo Animation Consumes Touch Event

Jack Cole

Well-Known Member
Licensed User
I am trying to use the Simple Halo Animation example to create a ripple like effect for button clicks. I have some complex content, so I overlay a panel over the content to catch the touch and produce the halo effect. The problem is that I can't see to have both the halo effect and catch the click event. I return False in the touch event. I show the code below and attached a sample project. Anyone know what the problem might be?

Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.

End Sub

Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.
    Private xui As XUI
    Private Button1 As Button
    Private Panel1 As Panel
End Sub

Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    Dim btn As Button
    btn.TextColor = Colors.White
    btn.Text = "Styled button"
    Activity.AddView(btn, 0, 0, 50%x, 10%y)
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

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.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
    Dim p As B4XView = iv
    Parent.AddView(p, x, y, 0, 0)
    Dim duration As Int = 200
    p.SetLayoutAnimated(duration, x - radius, y - radius, 2 * radius, 2 * radius)
    p.SetVisibleAnimated(duration, False)
End Sub
Sub Activity_Touch (Action As Int, X As Float, Y As Float)
    If Action = Activity.ACTION_DOWN Then
        CreateHaloEffect(Activity, X, Y, xui.Color_Blue)
    End If
End Sub

Sub Panel1_Touch (Action As Int, X As Float, Y As Float)
    If Action=Activity.ACTION_UP Then CreateHaloEffect(Panel1, X, Y, xui.Color_ARGB(100,255,255,255))
    Return False
End Sub

Sub Panel1_Click
End Sub