Android Question can we generalize 'make CLV move smooth' java object for any other view movement ?

AnandGupta

Expert
Licensed User
Longtime User
Refer,
How to make CLV move smooth ? | B4X Programming Forum

I have seen members using sleep() with position change of views to create slow movement of views.
Now Erel has shown using java object (I do not have much knowledge of it)

My query is can we generalize this java object for any other view movement ?
Like making a view move from top to bottom in a slow smooth way, say.

This code looks simpler to me than adding sleep after every step.
 

William Lancee

Well-Known Member
Licensed User
Longtime User
It is simpler. A view as B4XView has a SetLayoutAnimated method.
The following moves the button when pressed 300 to the right and 100 down in 3 seconds.
(Button1 is declared as a B4XView)

B4X:
Private Sub Button1_Click
    Button1.SetLayoutAnimated(3000, Button1.Left + 300, Button1.top + 100, Button1.Width, Button1.Height)
End Sub
 
Upvote 1

TILogistic

Expert
Licensed User
Longtime User
An example of moving views or objects
can be used to smoothly move towards an element in CLV

or use other smoothing functions
example.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
It is simpler. A view as B4XView has a SetLayoutAnimated method.
The following moves the button when pressed 300 to the right and 100 down in 3 seconds.
(Button1 is declared as a B4XView)

B4X:
Private Sub Button1_Click
    Button1.SetLayoutAnimated(3000, Button1.Left + 300, Button1.top + 100, Button1.Width, Button1.Height)
End Sub
Don't forget the dips:
B4X:
 Button1.SetLayoutAnimated(3000, Button1.Left + 300dip, Button1.top + 100dip, Button1.Width, Button1.Height)
 
Upvote 0
Top