LayoutTo is broken (forms v1.1.1)

JoeBoothJoeBooth USMember ✭✭
edited June 2014 in Xamarin.Forms

I have the following issue with LayoutTo

  1. I call LayoutTo to animate a AbsoluteLayout view (this works fine)
    ... the AbsoluteLayout view has number of subviews; some are hidden (Image & Label)
    ... i have a sequence where I hide a visible image & label and unhide a hidden image & label
  2. after doing the hide / unhide - the AbsoluteLayout is reset to it's original position

This was broken in the previous .forms version as well

LayoutTo code. Rectangle oldBounds = vwCommand.Bounds; Rectangle newBounds = new Rectangle (new Point (oldBounds.X, oldBounds.Y - (130 * V.Scale)), oldBounds.Size); vwCommand.LayoutTo (newBounds, 800, Easing.SinOut);

Posts

  • JoeBoothJoeBooth USMember ✭✭

    The layoutTo will also be reset if I change the .Source of an Image in a AbsoluteLayout

  • TheRealJasonSmithTheRealJasonSmith USXamarin Team Xamurai

    Instead of using LayoutTo, use TranslateTo. Translate is a post layout translation applied to an element intended for animation.

  • JoeBoothJoeBooth USMember ✭✭

    thanks @JasonASmith‌ - it works for most of my screens, however I have one animation which is changing the height of a view; - so TranslateTo won't work; I couldn't see a height adjustment animation and I tried setting the heightReqest after the LayoutTo but it still snaps back to the original height

  • JoeBoothJoeBooth USMember ✭✭

    @JasonASmith‌ TranslateTo does not seam to work at all on Android; note I'm only moving in the Y direction...

  • TheRealJasonSmithTheRealJasonSmith USXamarin Team Xamurai

    @JoeBooth‌ Can I see a repro, I just tested Translation on android

  • JoeBoothJoeBooth USMember ✭✭

    @JasonASmith‌ see below - can you also advise re animating the height of a view?

    this works fine on iOS but does nothing on Android...

            var _rootPageView = new AbsoluteLayout ();
            var _rootPage = new ContentPage () {
                BackgroundColor = Color.Black,
                Content = _rootPageView,
            };
            var _newRoot = new NavigationPage(_rootPage);
    
            var hello = new Label () {
                Text = "Hello",
                TextColor = Color.White,
            };
            _rootPageView.Children.Add (hello, new Point(10,10));
            hello.TranslateTo(110,250,3000,Easing.SinIn);
            return _newRoot;
    
  • DavidOakeyDavidOakey USMember

    I had the same problem, If you push the label to the bottom of the z order on Android it will "LowerChild" It will display and animate on top.

  • DanVanderboomDanVanderboom USUniversity ✭✭

    You can set the Opacity of panels you want to hide to 0, and to 1 for what you want to show. This gets around the problems on Android with IsVisible and a z-order change bug.

  • DanVanderboomDanVanderboom USUniversity ✭✭

    Correction to my previous post. Setting Opacity to 0 won't work: you'll see the content you want, but you may have transparent views on top which block you from tapping whatever's underneath.

    Where IsVisible doesn't work, I have had success in making the parent container clip to bounds, and then I TranslateTo (move) the view out of view.

    Ugly! But it works.

  • hi joebooth,
    like your code is working for me, but, i want to know how to change (slowdown) the animation time . Thank you

  • JacobPoulsen_JacobPoulsen_ DKMember ✭✭✭

    @VenkataSivaprasadReddyPulagam

    hello.TranslateTo(110,250,3000,Easing.SinIn);
    

    Replace 3000 with a higher number..

  • VenkataSivaprasadReddyPulagamVenkataSivaprasadReddyPulagam USMember ✭✭✭
    edited June 2016

    Thank you for the reply @JacobPoulsen_
    Is it same for LayoutTo animation also ?

  • JacobPoulsen_JacobPoulsen_ DKMember ✭✭✭
    edited June 2016

    @VenkataSivaprasadReddyPulagam Yes, except that LayoutTo takes Rectangle instead of x,y. Like this:

    test.LayoutTo(new Rectangle(x,y,width,height), 5000, Easing.SinIn);
    
  • PaulHoetsPaulHoets USMember ✭✭

    Just as a matter of interest, you can set anything to inputTransparent = true - what this does is makes a certain object transparent in terms of tapping and gestures, making the next view below it tappable, unless it too is set to inputtransparent, and so on.

    Its very irritating that LayoutTo is so busted up - it would be great feature, were it to function as it should....

    But as for adjusting the size to what you want it to finally be, might I suggest the following:

                while (navBar.Height < 100)
                { navBar.HeightRequest = navBar.HeightRequest + 1;
                    await navBar.ScaleTo(1, 50);
                }
    

    Lacking brain cells in quality, and quantity however, I leave it to smarter people to suggest how to add interpolation/easing. I was bad at maths when I was small. :(

Sign In or Register to comment.