Android Code Snippet [B4X] ShakeView

[By Erel]

B4X:
Sub ShakeView (View As B4XView, Duration As Int)
   Dim Left As Int = View.Left
   Dim Delta As Int = 20dip
   For i = 1 To 4
       View.SetLayoutAnimated(Duration / 5, Left + Delta, View.Top, View.Width, View.Height)
       Delta = -Delta
       Sleep(Duration / 5)
   Next
   View.SetLayoutAnimated(Duration/5, Left, View.Top, View.Width, View.Height)
End Sub

B4X:
Sub Button1_Click
   ShakeView(EditText1, 500)
End Sub

Add a reference to XUI.
 
Last edited:

Alexander Stolte

Expert
Licensed User
Longtime User
An example and a gif would be premium...

2020-09-11-12-06-06-min.gif
 

Attachments

  • ShakeView Example.zip
    9.5 KB · Views: 295
Top