Android Question Original Ripple Effect

AmirMK82

Member
Licensed User
HI, 👋
Thanks B4X Team For Developing b4a :)

I Have A Question:
How can I use Android original ripple effect for Buttons and Imageviews??
I tested some libraries but they didn't good :(
Please Give Me A Good Library Or Give me a code for Android Original ripple effects on imageview and buttons.

Thanks In Advance.🌺
 

Alexander Stolte

Expert
Licensed User
 
Upvote 0

AmirMK82

Member
Licensed User
Hi,
thanks for you answer
But I didnt mean that
I want this one👇

rv.gif
 
Upvote 0

Alexander Stolte

Expert
Licensed User
Then you need this:
Remove the for next loop
B4X:
For i = 1 To 5
   CreateHaloEffectHelper(Parent,bmp, x, y, clr, radius)
   Sleep(800)
Next
To
B4X:
CreateHaloEffectHelper(Parent,bmp, x, y, clr, radius)
Sleep(800)
 
Upvote 0

AmirMK82

Member
Licensed User
Now I get new error

main$ResumableSub_CreateHaloEffectHelperresume (java line: 522)
java.lang.RuntimeException: Type does not match (class android.widget.Button)
at anywheresoftware.b4a.objects.B4XViewWrapper.typeDoesNotMatch(B4XViewWrapper.java:387)
at anywheresoftware.b4a.objects.B4XViewWrapper.asPanelWrapper(B4XViewWrapper.java:108)
at anywheresoftware.b4a.objects.B4XViewWrapper.AddView(B4XViewWrapper.java:323)
at b4a.exampcvbnm.main$ResumableSub_CreateHaloEffectHelper.resume(main.java:522)
at b4a.exampcvbnm.main._createhaloeffecthelper(main.java:478)
at b4a.exampcvbnm.main$ResumableSub_CreateHaloEffect.resume(main.java:453)
at b4a.exampcvbnm.main._createhaloeffect(main.java:375)
at b4a.exampcvbnm.main._activity_create(main.java:352)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:213)
at b4a.exampcvbnm.main.afterFirstLayout(main.java:105)
at b4a.exampcvbnm.main.access$000(main.java:17)
at b4a.exampcvbnm.main$WaitForLayout.run(main.java:83)
at android.os.Handler.handleCallback(Handler.java:883)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:237)
at android.app.ActivityThread.main(ActivityThread.java:8019)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1100)




this is error👆
and this is my codes👇

B4X:
#Region  Project Attributes
    #ApplicationLabel: B4A Example
    #VersionCode: 1
    #VersionName:
    'SupportedOrientations possible values: unspecified, landscape or portrait.
    #SupportedOrientations: unspecified
    #CanInstallToExternalStorage: False
#End Region

#Region  Activity Attributes
    #FullScreen: False
    #IncludeTitle: True
#End Region

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

Sub Globals
    'These global variables will be redeclared each time the activity is created.
    Private Button1 As B4XView
End Sub

Sub Activity_Create(FirstTime As Boolean)
    Activity.LoadLayout("Layout")
    
    CreateHaloEffect(Button1, 5%x, 10%y,xui.Color_Red)
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Sub Button1_Click
    xui.MsgboxAsync("Hello world!", "B4X")
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.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
 
Upvote 0
Top