Other Simple animations in B4A v4.00

Discussion in 'Android Questions' started by Erel, Dec 3, 2014.

  1. Erel

    Erel Administrator Staff Member Licensed User

    Three new features that will soon be available:

    1. Screen video recording based on the new ADB feature:


    This feature requires an Android 4.4 device. It is very useful for demonstrations.

    2. Simple animations. Three new methods were added to the View objects which make animations very simple:
    View.SetLayoutAnimated - Similar to View.SetLayout. Allows you to change the view size and position. The change is animated.
    View.SetVisibleAnimated - Similar to View.Visible. Fades in or out the view.
    View.SetColorAnimated - Similar to View.Color. Animates the color change (based on the HSV color space).

    See this video for an example (it looks smoother on the device), click on the small gear button and change to HD:

    The complete code:
    Sub Globals
    Private btnMove As Button
    End Sub

    Sub Activity_Create(FirstTime As Boolean)
    End Sub
    Sub btnHide_Click
    End Sub

    Sub btnShow_Click
    End Sub

    Sub btnMove_Click
    1000Rnd(090%x), Rnd(090%y), Rnd(50dip200dip), Rnd(50dip200dip)) 
    End Sub

    Sub btnColors_Click
    Activity.SetColorAnimated(1000Colors.White, Colors.Red)
    End Sub
    3. Layout animations. Layouts created with the designer are optionally animated. The animation is based on the views anchors:

    Note that the animations are based on APIs introduced in Android 4.0. On older devices the methods changes will be applied without animations.
  2. ivanomonti

    ivanomonti Well-Known Member Licensed User

  3. Douglas Farias

    Douglas Farias Expert Licensed User

    1° = my sugestion *-*-*-*-*-*-* tyty

    question, its possible save the video on the pc @Erel ?
    for example, i make a app, now i want make a video for put on ggplay, its possible add a option to make a video and save on the pc?
  4. Powie

    Powie Member Licensed User

    grat news!!!!!!
  5. asales

    asales Well-Known Member Licensed User

  6. Erel

    Erel Administrator Staff Member Licensed User

    Yes, this is how it works. When you click on the Stop button the standard save file dialog appears and the file is saved on the PC. The temp file field is used during recording. In most cases you do not need to change it.
    Douglas Farias likes this.
  7. thedesolatesoul

    thedesolatesoul Expert Licensed User

    Is there a way to chain animations? So once one of them finishes we can start the next?
    Cableguy likes this.
  8. Erel

    Erel Administrator Staff Member Licensed User

    The important point about these three methods is that they are very simple to use. For example instead of calling Button1.Visible = False you call Button1.SetVisible(1000, False) and you get a nice animated effect.
    For more complex animations you can use the Animation or AnimationPlus libraries. You can also use a timer to chain animations.

    Note that these three methods are similar to B4i animation methods.
  9. thedesolatesoul

    thedesolatesoul Expert Licensed User

    I see.
    So what other goodies are coming in this major revision update? :)
    Peter Simpson likes this.
  10. JoanRPM

    JoanRPM Active Member Licensed User

    Very interenting.
  11. Cableguy

    Cableguy Expert Licensed User

    Will it be possible to catch animation_finished event?
  12. Douglas Farias

    Douglas Farias Expert Licensed User

    what the prevision to b4a 4.00 ?
  13. Ratna Fang

    Ratna Fang Member Licensed User

    awesome, erel.

    just can't wait for the release.
  14. Peter Simpson

    Peter Simpson Expert Licensed User

    Hmm, interesting and simple to use :)
  15. Inman

    Inman Well-Known Member Licensed User

  16. LucaMs

    LucaMs Expert Licensed User


    (just because there was too much sugar :D)
    magoandroid likes this.
  17. Shadow&Max

    Shadow&Max Active Member Licensed User

    Pretty slick Erel!
  18. Jim Brown

    Jim Brown Active Member Licensed User

    One thing to be aware of, at least with my limited testing, is to avoid calling the same commands close together. Otherwise the followup command is ignored because the first is still running:

    250True' Likely to be missed
  19. Troberg

    Troberg Well-Known Member Licensed User

    Found a little bug (or oddity, depending on how you view it).

    I have a panel with a few child views on it. When I use SetLayoutAnimated to move it and make it larger, the child views scale nicely and it looks like an entire unit being moved in and slightly enlarged, just like it should.

    However, when I go the other way, and make it smaller, the child controls won't scale, instead, they'll remain full size as the panel shrinks.

    Here's the relevant code:

    Sub ShowControls(Show As Boolean)

    If Show Then
    5000%x100%y -panControls.Height, 100%x, panControls.Height)
    50020%x100%y80%x, panControls.Height)
    End If
    End Sub
    panControls, of course, is the panel with child views on it.
    Last edited: Dec 11, 2014
  20. Troberg

    Troberg Well-Known Member Licensed User

    And, ignore my previous post. It's just me who can't type. 80<>60...

    Edit: and, no, something's still strange. When making it smaller, it looks like it first places every child which, if they were large size, would fit on the smaller size (so, kind of stretched, and some of them at the right edge missing), then resize them to the smaller size.

    To duplicate, just make a panel, add some view to it and toggle between large and small size.
    Last edited: Dec 11, 2014
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice