iOS Question ScaleCenter Animation

Mike1970

Well-Known Member
Licensed User
Longtime User
hi, i was looking for the ScaleCenter Animation (that on B4A is included in the Animation Library).
There is something to achieve the same result on ios?
Thanks
 

ilan

Expert
Licensed User
Longtime User
do you want to animate a view? you can use the "SetLayoutAnimated" function for that and change the size and the position of the view.
 
Upvote 0

Mike1970

Well-Known Member
Licensed User
Longtime User
do you want to animate a view? you can use the "SetLayoutAnimated" function for that and change the size and the position of the view.
Yes, it's what i tried to do, but i didn't achieved a good result.
I would like to have a cricle (for semplicity a rectangle) positioned in the center, and then animate it to expand from the center to fill up all the screen. (the pivot in the center not in a corner)
 
Upvote 0

Mike1970

Well-Known Member
Licensed User
Longtime User
can you post your code

B4X:
Dim p As Panel
    p.Initialize("")
    p.Color = Colors.red
    Dim h As Int = 100dip
    Dim w As Int = 100dip
   
    Page1.RootPanel.AddView(p, 50%x-w/2, 50%y-h/2, w, h)
   
    Sleep(1000)
   
    Dim h2 As Int = 300dip
    Dim w2 As Int = 300dip
    p.SetLayoutAnimated(1000, 1, 50%x-w2/2, 50%y-h2/2, w2, h2)

I didn't post it because i know it's wrong, i thought there was a similar "ScaleCenter" function somewhere
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Check this: https://www.b4x.com/android/forum/threads/b4x-xui-simple-halo-animation.80267/#content

halo-gif.56306
 
Upvote 0

ilan

Expert
Licensed User
Longtime User
B4X:
Dim p As Panel
    p.Initialize("")
    p.Color = Colors.red
    Dim h As Int = 100dip
    Dim w As Int = 100dip

    Page1.RootPanel.AddView(p, 50%x-w/2, 50%y-h/2, w, h)

    Sleep(1000)

    Dim h2 As Int = 300dip
    Dim w2 As Int = 300dip
    p.SetLayoutAnimated(1000, 1, 50%x-w2/2, 50%y-h2/2, w2, h2)

I didn't post it because i know it's wrong, i thought there was a similar "ScaleCenter" function somewhere

i have tried your code on b4j and it works fine. i dont see any issue.

B4X:
    Dim p As Pane
    p.Initialize("")
    CSSUtils.SetBackgroundColor(p,fx.Colors.red)
    Dim h As Int = 100dip
    Dim w As Int = 100dip
    Dim mw, mh As Float
    mw = MainForm.RootPane.Width
    mh = MainForm.RootPane.Height
    MainForm.RootPane.AddNode(p, (mw/2)-(w/2), (mh/2)-(h/2), w, h)
    Sleep(1000)
    Dim h2 As Int = 300dip
    Dim w2 As Int = 300dip
    p.SetLayoutAnimated(1000,(mw/2)-(w2/2), (mh/2)-(h2/2), w2, h2)

make sure you do the animation after Page_Resize event!
i would also recommend you to create 2 variables with the height and width of the page that you should set in the page_resize event and then use them instead of using 50%x/50%y. like i do with mw and mh.
 
Upvote 0
Top