Android Question animation

samannnn

Member
i want to have an animation in my app. i create that and it works correctly, But I am not sure if my method is correct or not.

i repeate this code more by pressing Btnpress and i think it is not correct to Initialize pnlanimation every time.

thanks for your suggestion.

B4X:
Sub Begin
    pnlmainanimat.Initialize("")
    Root.AddView(pnlmainanimat,Root.Width/1.2,Root.Width/8,Root.Width/6,Root.Height/2)
End Sub

Sub TonAnimation
    For i=0 To pnlanimation.Length-1
        pnlanimation(i).Initialize("")
        pnlmainanimat.AddView(pnlanimation(i),pnlmainanimat.Width/(Rnd(5,25)),pnlmainanimat.Height/1.5,pnlmainanimat.Width/9,pnlmainanimat.Width/9)
        pnlanimation(i).SetBackgroundImage(LoadBitmap(File.DirAssets,"note_"&Rnd(2,4)&".png"))
        moveview(pnlanimation(i),Rnd(4000,6000))
    Next
   
End Sub

Sub moveview(View As B4XView, Duration As Int)
    Dim Delta As Int = 20dip
    View.SetLayoutAnimated(Duration / 5, View.Left+Delta*(Rnd(1,5)) , View.top-Delta*10, View.width, View.height)
    View.SetVisibleAnimated(1000,False)
    View.RemoveAllViews
End Sub

Sub Btnpress_Click
   TonAnimation
End Sub
 

Attachments

  • Rec 0004.gif
    Rec 0004.gif
    261.1 KB · Views: 119

samannnn

Member
1. Don't use the Animation library.
2. Change the views type to B4XView.
3. Use B4XView built-in animated methods.
thanks for your replay.

I dont use animation library and just use SetLayoutAnimated. is it correct or not?

is it correct to Initialize some panels for each time i press key to show animations? is there a best way for that?
 
Upvote 0
Top