Android Question Shake Edittext

Douglas Farias

Expert
Licensed User
Longtime User
Hi, how to make in b4a a shake edittext effect?
i see on many many apps on googleplay, edittext with shake

for example

have

edLogin
edPass
Button

if you enter with login only and press a button the app shake and vibrate a edPass
 

sorex

Expert
Licensed User
Longtime User
it will work like that but you need to code it so that it works right.

the routine itself doesn't do much, you need to use it in a timer.

when the button is clicked you check the edittext value if it's "" enable the timer where the shake is in and let it shake for 10 times or so and then disable the timer again.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Here:
B4X:
Sub Globals
   Private EditText1 As EditText
   Private shake As Animation
End Sub

Sub Activity_Create(FirstTime As Boolean)
   Activity.LoadLayout("1") 'Includes EditText1
   shake.InitializeTranslate("", -10dip, 0, 10dip, 0)
   shake.RepeatCount = 5
   shake.RepeatMode = shake.REPEAT_REVERSE
   shake.Duration = 50
End Sub

Sub Activity_Click
   shake.Start(EditText1)
End Sub
 
Upvote 0

susu

Well-Known Member
Licensed User
Longtime User
I used to change Left and Top of a view to make shake effect.
 
Upvote 0
Top