Bug? SetLayoutAnimated

Discussion in 'Bugs & wishlist' started by LucaMs, May 19, 2018.

  1. LucaMs

    LucaMs Expert Licensed User

    I wanted to animate a panel, from its initial width to zero.

    If you set:
    Panel1.SetLayoutAnimated(500, Panel1.Left, Panel1.Top, 0, Panel1.Height)
    the panel disappears immediately, instead of do it in 500ms.

    I noticed that a panel added by Designer has its border width set to 2dip.
    Then you must set the minimum new width to the border width + 1dip to get the correct animation,
    but if you set the new width to zero, the animation will not happen even if you set the border width to zero.

    Also, even if you get the right animation, at least on my tablet with Android 4.4.2 - 1280x800 - scale 1, traces of the previous "image" remain:

    They are not so visible in the animated gif, maybe:

    Finally, if during the animation you increase the width of the panel, its content remains visible (it too will be animated), while in the opposite direction, decreasing the width, it disappears (as you can see in the animated gif above).

    P.S. no traces on another device, Android 7 - 1920x1080 - scale 2.5

    Attached Files:

    Last edited: May 19, 2018
  2. mangojack

    mangojack Well-Known Member Licensed User

    I am having the same issue.

    A panel added with designer containing an image.
    If you use SetLayoutAnimated from its current size to a width of 0 , the panel resizes instantaneously. (there is no animation)

    If the new width is set to 1dip the animation takes place but the image is quickly blurred prior to resizing.

    Resizing the panel back to original size animates correctly .. (with the image also resizing correctly)

    * ( unlike @LucaMs .. in the designer , when adding a panel there is no default border size ?)

    Attached Files:

  3. LucaMs

    LucaMs Expert Licensed User

    No, the default is 0; but Luca (which I don't know :p) often forgets what he does :cool: (he had set the value to 2).

    But if you set that value, then you need to set the value of the animation to that value + 1 dip.
  4. LucaMs

    LucaMs Expert Licensed User

    There is a workaround (although this forces me to write extra code in a library... really not very useful):
    use two animations for... each animation.

    Panel1.SetLayoutAnimated(500, Panel1.Left, Panel1.Top, 1dip, Panel1.Height)
    500, Panel1.Left, Panel1.Top, 0, Panel1.Height)
    In my case, where you may have a variable minimum value, not always 0, I need more code.
    (not tested, but something similar to this should help).

    Unfortunately, I don't know workarounds for:
    and not even for this:
    Last edited: May 19, 2018
  5. Erel

    Erel Administrator Staff Member Licensed User

    This is related to the way animations are implemented. It immediately sets the view's layout to the target layout and then animates it by animating the scale and translation properties. It makes it simple to use SetLayoutAnimated as the layout state is consistent.

    The view will immediately disappear if you set its target size to zero as the scale will have no effect.
  6. LucaMs

    LucaMs Expert Licensed User

    Perfect, I understood ... nothing :p

    I suppose there are no solutions.

    About this:
    I suppose that the problem can be the anti aliasing (?)
  7. LucaMs

    LucaMs Expert Licensed User

    There is one:


    Using NineOldAndroids :D (I hope it will work always with B4XViews; here it works).

    I have to find why if I set a bitmap in an ImageView using LoadBitmapResize I get the right image but if I do it with a B4XView I get a "zoomed image"; probably Fill / Center settings stuff)
    Last edited: May 20, 2018
  8. Erel

    Erel Administrator Staff Member Licensed User

    The animation itself is managed by the OS. So the traces left is an Android issue.
    LucaMs likes this.
  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