question-mark
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.

ScrollView doesn't work properly on Android.

See original GitHub issue

Description

When I wrap a ScrollView around a VerticalStackLayout in Android specifically, or any other control really, if the controls exceed the viewing area, it’s not possible to scroll, and everything is simply truncated. https://i.imgur.com/fwfnTfi.png This same project works completely fine on Windows, though, and scrolling works perfectly. Here is the xaml:

<ScrollView>
        <VerticalStackLayout 
            Spacing="16" 
            Padding="30,30" 
            VerticalOptions="Start">

            <Label
                x:Name="titleLabel"
                FontSize="32"
                FontFamily=""
                FontAttributes="Bold"
                Text="Loading..." />

            <Label
                x:Name="descriptionLabel"
                FontSize="18"
                FontFamily=""
                FontAttributes="None"
                Text="Loading..." />

            <Image
                x:Name="apodImage"
                Margin="0, 30"
                Source="loading.png"
                HeightRequest="200"
                Aspect="AspectFit" />

            <Button
                x:Name="refreshButton"
                IsEnabled="False"
                Text="Refresh" 
                Clicked="refreshButton_Clicked" />

            <Button
                x:Name="shareButton"
                IsEnabled="False"
                Text="Share" 
                Clicked="shareButton_Clicked" />

        </VerticalStackLayout>
    </ScrollView>

Thanks for your time!

(Top part of the code which keeps getting cut off): image

Steps to Reproduce

  1. Create a new .NET MAUI project.
  2. In the default VerticalStackLayout, add some controls and then change their initial size at runtime.
  3. Run the project on Android.

Version with bug

6.0 (current)

Last version that worked well

Unknown/Other

Affected platforms

Android

Affected platform versions

All Android versions

Did you find any workaround?

edit see: https://github.com/dotnet/maui/issues/7590#issuecomment-1164968260

Relevant log output

No response

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:20 (1 by maintainers)

github_iconTop GitHub Comments

4reactions
fyndorcommented, Jun 23, 2022

This is my workaround for now. Every time I do something in my ViewModel that I know should affect the vertical height of the page, I call an Action that I assign to this method. By setting the Content property to null, and then back to it’s value as defined in XAML, it recalculates it’s size and works properly.

private void NotifyScrollChanged()
{
    var content = ScrollViewCtrl.Content;
    ScrollViewCtrl.Content = null;
    ScrollViewCtrl.Content = content;
}
4reactions
Dan-Banfieldcommented, May 31, 2022

same here, scrolling doesnt work when we have verticalstacklayout inside scrollView. On android doesnt work at all, on Windows works ok. One thing when I populate data during initialization in constructor scrolling works properly so it seems that the problems is in “resizing” layout after initialization

Yup. Exactly the same here. A really big problem actually; I don’t even know how this went unnoticed?

Read more comments on GitHub >

github_iconTop Results From Across the Web

android - ScrollView not scrolling at all
Answer: the ScrollView is not working when used as the root element of an XML layout. It has to be wrapped inside a...
Read more >
Scroll view not scrolling on Android
I've found why this is happening: the scroll view works when the screen config is set to "NOT SCROLLABLE". When the screen is...
Read more >
Scroll View Problem. Solution of Scroll View in Android Studio ...
Android Studio Not work Offline: https://www.youtube.com/watch?v=xyyw2FxWSwE&t=7s How to Add App Update Button (Tab) on Menu User check App ...
Read more >
Common bugs in React Native ScrollView and how to fix ...
The first and most common mistake of using ScrollView is not knowing when to use it. There are two common List components in...
Read more >
Working with the ScrollView | CodePath Android Cliffnotes
When an app has layout content that might be longer than the height of the device and that content should be vertically scrollable,...
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 Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found