Android Question SetLayoutAnimated not working properly ?

Discussion in 'Android Questions' started by JTmartins, Mar 7, 2015.

  1. JTmartins

    JTmartins Active Member Licensed User

    I have this litle piece of code.

    What is happening is that the panel opens smoothly in a "animation", however it does not "animate" when it is suposed to close down.

    It simply vanishes exactly as if I did pnlScore.visible=false.

    What am I doing Wrong ?

    Many thanks

    JM

    Code:
    Sub igvMenuScore_Click
        
    If flagmenuscores=False Then
            pnlScore.Height=
    0
            pnlScore.Width=
    0
            pnlScore.Visible=
    True
            pnlScore.SetLayoutAnimated(
    200,85%x,49%y,13%x,51%y)
            flagmenuscores=
    True
        
    Else
            pnlScore.SetLayoutAnimated(
    200,85%x,49%y,0%x,0%y)
            flagmenuscores=
    False
        
    End If 
     
    End Sub
    PS - Just noticed now that If I use 1%x and 1%y it does "animate", however it does not suit my purpose as a litle bit stays there. If I do a pnlscore.visible=false, after the "animation" it vanishes without any animation (I presume because the instruction is reached a few miliseconds later, so the animation will not run.
     
    Last edited: Mar 7, 2015
  2. eurojam

    eurojam Well-Known Member Licensed User

    Indeed, it is an interesting behavior:
    Code:
    pnlScore.SetLayoutAnimated (  200,85%x,49%y,1dip,1dip)
    works like expected and
    Code:
    pnlScore.SetLayoutAnimated(200,85%x,49%y,0,0)
    do not....strange...:confused:
     
  3. Erel

    Erel Administrator Staff Member Licensed User

    Seems like you are hitting an internal optimization of Android where it hides the view if its size is 0. This causes the animation to be hidden as well.

    Use 1dip and combine it with a call to SetVisibleAnimated to completely hide it.
     
    JTmartins likes this.
  4. Johan Schoeman

    Johan Schoeman Expert Licensed User

    I have also found different behaviour between two different devices when using SetLayoutAnimated and it took me almost a day to get it sorted out...using/calling INVALIDATE. Not sure if it is relevant to the above problem but it did sort out the problem I had.
     
Loading...
  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