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.

[ANDROID] ScrollView not increasing in height when its child ListView or CollectionView are getting more items

See original GitHub issue

Description

At first it looked like scrolling isn’t working any more, then I realised lager pages are scrolling fine, made some testing and realised height of ScrollView on Android is always the same as when the page is rendered first time. If you add more items into ListView or CollectionView they will push elements bellow them into invisibility. Going to next page and returning back did not help.

Steps to Reproduce

Microsoft Visual Studio Community 2022 (64-bit) - Preview Version 17.2.0 Preview 6.0 create MauiCollectionViewTestV172P6 project MauiCollectionViewTestV172P6-scrollviewnotincreasingheightonandroid.zip

There are both CollectionView and ListView in XAML, uncomment the one you want to use. Buttons are added to make the page bigger than one screen to make it scrollable on first rendering. In c# you can uncomment code to add 30 objects to either list or ObservableCollection also different possibilites of populating the view are possible - just uncomment the one you want. await DisplayAlert(“ScrollViewSize”, ScrollView1.ContentSize.ToString(), “OK”); will display message with size of the scrollview after eack click. On WINDOWS he height option changes when new objects are displayed, on Android it always stays the same number.
ALSO it won’t decrease in size either try: add 30 objects by uncommenting code after InitializeComponent() Change NextPage Button so it will delete all collection elements

private async void ClickedButtonNextPage(object sender, EventArgs e)
	{
		while (collection.Count > 0)
		{
			collection.RemoveAt(0);
		}
	}

On WINDOWS size will decrease but on ANDROID ScrollView height will remain large and there will be a large white area after the last element at the end of the page when you scroll down.

Version with bug

Release Candidate 2 (current)

Last version that worked well

Unknown/Other

Affected platforms

Android

Affected platform versions

Tested on Android 5 and 9

Did you find any workaround?

No response

Relevant log output

No response

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
CobaltGoldCScommented, May 29, 2022

I’m having the same issue when manually updating the contents of the Scrollview in any way that changes their size.

There are a few issues that seem to be addressing the same issue, such as #7374

EDIT: As a follow-up, manipulating content sizes inside scrollviews does not cause issues in windows as far as I have found

0reactions
jfversluiscommented, Jul 6, 2022

Verified this is fixed in our current codebase. Should be released as part of the next service release. Thanks everyone for the help and input here!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Listview/Recycler View is not expanding in Scrollview/ ...
I searched a lot on internet, due to listview in scroll view and both objects have scrolling abilities that is why one object...
Read more >
ScrollView
Scroll view may have only one direct child placed within it. To add multiple views within the scroll view, make the direct child...
Read more >
Xamarin.Forms ScrollView
A ScrollView requires a specific height to compute the difference between the height of its content and its own height, with the difference...
Read more >
ScrollView - .NET MAUI
To scroll its child content, ScrollView computes the difference between the height of its content and its own height.
Read more >
GridView class - widgets library - Dart API
To create a linear array of children, use a ListView. To control the initial scroll offset of the scroll view, provide a controller...
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