Android Question Simple loader Gif Animation with rotate image

ALBRECHT

Active Member
Licensed User
Hello,

I have a simple script to animate a loader image
during a wait for poststring class. It's works great but between each loop of the rotation there is a few waiting second ?

like that :

b4xce-01.gif


the code :

B4X:
Dim POStr As POSTstr
        Dim imgload As Animation
        ImgConnLoad.Width = 45dip
        ImgConnLoad.Height = 45dip
        ImgConnLoad.Visible = True
        imgload.InitializeRotateCenter("", 0, 360, ImgConnLoad)
        imgload.Start(ImgConnLoad)
        imgload.Duration = 1000
        imgload.RepeatCount = -1

        'Process Class
        POStr.Initialize(BoServerAddConnect, PSParams, "JobAddConn")
        Wait For (POStr.SendPost) complete(resPOStr As String)

        imgload.Stop(ImgConnLoad)
        ImgConnLoad.Visible = False

If you have an idee to make a rotation loop more fluid ?
 

Brandsum

Well-Known Member
Licensed User
This following code sample is a B4X solution.

B4X:
Sub RotateInfinite(v As B4XView)
    Do While v.tag
        v.Rotation = v.Rotation + 5 'change this value for rotation speed
        Sleep(10)
    Loop
End Sub

'to start animation set view tag to true and call rotate function
ImgConnLoad.tag = true
RotateInfinite(ImgConnLoad)

'to stop animation set view tag to false
ImgConnLoad.tag = false
 
Last edited:
Upvote 0
Top