Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 58056

problem with LayoutTo and positioning of subsequent views

$
0
0

Hi everyone.
In the application I am working on I need to show/hide a view whenever a button is clicked. I have achieved this by simply setting IsVisible to true or false. But I would like to show a slide down/up animation whenever the visibility is changed.

I have experimented with the LayoutTo method and it works! Well, almost...

I create two rectangles to use as bounds

_openBounds = _header.Bounds; 
_closedBounds = new Rectangle(_openBounds.Location,new Size(_openBounds.Width,0));

And then I use the LayoutTo method to swap between them:

public async void HideOrShow(object sender, EventArgs eventArgs)
            {
                if (_firstRun)
                {
                    SetBounds();
                    _firstRun = false; 
                }

                uint animationTime = 900;
                if (_shown)
                {
                    //_header.LayoutTo(_closedBounds, animationTime, Easing.CubicOut);
                    _shown = false;
                }
                else
                {
                    _header.LayoutTo(_openBounds, animationTime, Easing.CubicIn);
                    _shown = true;
                }

                _btnOpenClose.Text = _shown.ToString(); 
            }

My problem is that the space made available by changing the bounds isn't filled by the subsequent views in the stacklayout (see images below). Is this a bug or am I trying to do something this method wasn't designed for?

Is there some other way I can achieve the same thing?

Thanks in advance and have a great day


Viewing all articles
Browse latest Browse all 58056

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>