Sub AnimateView(View As B4XView, Duration As Int, Left As Int, Top As Int, Width As Int, Height As Int)
Dim cx As Int = Left + Width / 2
Dim cy As Int = Top + Height / 2
View.SetLayoutAnimated(0, cx, cy, 0, 0)
Dim start As Long = DateTime.Now
Do While DateTime.Now < start + Duration
Dim p As Float = (DateTime.Now - start) / Duration
Dim f As Float = 1 - Cos(p * 3 * cPI) * (1 - p)
Dim w As Int = Width * f
Dim h As Int = Height * f
View.SetLayoutAnimated(0, cx - w / 2, cy - h / 2, w, h)
Sleep(16)
Loop
View.SetLayoutAnimated(0, Left, Top, Width, Height)
End Sub