Android Question Panel animation messed up after panel.loadLayout

Jason Wood

Member
Licensed User
I have a panel (created in Main activity code called pnlGame), set to full screen height/width and which is offset to the right of the screen, i.e. pnlGame.Left = 100%x so it can't be seen.

A click animates this panel into view using translate (ending with Left = 0) so it slides into view from the right, covering the whole screen.

The idea is that this panel will have a different layout loaded, depending on which level the user selects.

B4X:
' LOAD LAYOUT INTO GAME PANEL
    pnlGame.LoadLayout("gameLevel" & LevelSelected)
   
    ' SLIDE GAME PANEL INTO VIEW
    Dim Anim As Animation
    Anim.InitializeTranslate("Animation", 0,0,-100%x,0)
    Anim.Duration = 300
    Anim.RepeatCount = 0
    Anim.Start(pnlGame)

The gameLevel layout is created in the designer.

With ' pnlGame.LoadLayout("gameLevel" & LevelSelected)' commented out, the panel itself (with no loaded content) slides into view perfectly. However, If I load the 'gameLevel' layout into the panel, the animation is messed up.

It seems as if the whole outer containing panel, pnlGame, is reduced in size, and as it slides left as per the animation, it grows in width and height until it fills the whole screen.

It seems as if when the game layout is loaded into the panel, it is no longer aware of the screen size and shrinks down. But as it animates it, it becomes aware of the screen size and increases in size to match the screen! At least that;s the impression I get.

I wish I could take a video of it so it's clear what I mean.

Does anyone know why this could be happening? Thanks.
 

JordiCP

Expert
Licensed User
Longtime User
Have you tried, in the designer, to click on the main container, and set "Animation Duration" to 0 ?
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…