Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Secondary view doesn't resize when (eg) rotating the device

See original GitHub issue

I’m trying to use ExpandableView to show a bit of text in the expanded view. This means that, depending on screen/window width and the length of the text, it can flow into several lines.

What I’ve found was that the secondary view’s height is kept following the first initialisation of the view, so when I rotate the device it will either clip the content or show additional blank space.


In order to get the control to work roughly as expected I have had to implement a few changes to the ExpandableView.cs class, adding this override for OnSizeAllocated.


    private double _previousWidth;

    protected override void OnSizeAllocated(double width, double height)
        base.OnSizeAllocated(width, height);

        if (width == _previousWidth)
            //nothing to do
        else if (this.Status != ExpandStatus.Expanded && this.Status != ExpandStatus.Expanding)
            // secondaryview is not visible, we should reset it so that it'll appear in the correct size when active
            _lastVisibleHeight = -1;
        else if ( this.Status != ExpandStatus.Collapsed && this.Status != ExpandStatus.Collapsing)
            // secondaryview is visible, needs resizing to fit new width
            this.SecondaryViewHeightRequest = -1;

        this._previousWidth = width;

Out of a few attempts at fixing this, this was the most complete solution:

  • it resizes on UWP when resizing the window.
  • it resizes when rotating the device the secondary view is open.
  • it resizes correctly when you open the view, close it and rotate the device/resize the window, then reopen the view.

I am very keen on using this control (nice work Andrei), but can’t really do it without fixing this problem. Am I close to a (good enough) fix for the problem or have I somehow not noticed how resizing is supposed to be handled?


Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:11 (6 by maintainers)

github_iconTop GitHub Comments

MitchBomcanhaocommented, May 1, 2019

Well, my workaround isn’t necessarily the neatest code, it’s just where I got to to make it work - feel free to take the code, try it and change it if needed.

MitchBomcanhaocommented, May 7, 2019

You’re right - I am likely overlooking many scenarios, as expandableview can be used in many different layouts. I didn’t care about height changes because I’ve made my layout consistent for the primaryview and only the secondaryview can have linebreaks in its content. I haven’t seen how primary view reacts with similar content.

Read more comments on GitHub >

github_iconTop Results From Across the Web

My app's main view doesn't resize to fill the screen when ...
My app's main view doesn't resize to fill the screen when the device is rotated · Subscribe to RSS.
Read more >
Why doesn't my view auto resize after rotation?
I have an app using the splitscreen controller. The detail view part of it does not resize when the iPad orientation changes. All...
Read more >
IPhone Rotation, View Resizing and Layout Handling
Having rotated the device, only the top button is visible and it is still centered assuming that the device is in portrait mode....
Read more >
Build a responsive UI with ConstraintLayout
To select a different sizing mode, click a view and open the Attributes window on the right side of the editor.
Read more >
Expo ScreenOrientation
A universal library for managing a device's screen orientation. Screen Orientation is defined as the orientation in which graphics are painted on the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found