Android Question SetLayoutAnimated with childviews

Blueforcer

Well-Known Member
Licensed User
Longtime User
As you can see in the gif, i have a panel with some labels in it.
Now i only want to resize the root panel animated, but the childviews looks crazy during the animation.
How can i avoid this?



resize.gif
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Use this code:
B4X:
Private Sub SetHeightAnimated(v As B4XView, NewHeight As Int, Duration As Int)
    Dim startTime As Long = DateTime.Now
    Dim startHeight As Int = v.Height
    Dim deltaHeight As Int = NewHeight - startHeight
    Dim t As Long = DateTime.Now
    Do While t < startTime + Duration
        Dim h As Int = startHeight + deltaHeight * (t - startTime) / Duration
        v.Height = h
        Sleep(10)
        t = DateTime.Now
    Loop
    v.Height = NewHeight
End Sub

It should be smooth in release mode.
 
Upvote 0
Top