Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

[Bug] Image in ScrollView causes content to truncate at end on Android #13398

Open
IMLizKing opened this issue Jan 13, 2021 · 4 comments
Open

Comments

@IMLizKing
Copy link

IMLizKing commented Jan 13, 2021

Description

I find that if I put an Image into a stacklayout contained in a scrollview (within a ContentPage) that the bottom of the scrollview content will be truncated and only show the background color of the scrollview in the space that should display the content. Not co-incidentally, the amount of blank space equals the height of the rendered image. And if you request a height for the image (ala HeightRequest) the problem goes away.

Steps to Reproduce

  1. Start with a new Mobile App (Xamarin.Forms) project, using the Blank template, targeting Android
  2. Make sure it builds (this isn't always the case)
  3. Wrap the MainPage in a ScrollView and add enough content to make it scroll vertically
  4. Add some sort of image to the content as well (e.g.
  5. Run on Android (things seem fine on iOS and UWP) and notice the bottom of the scrollview content being blank

Expected Behavior

Seeing all the content contained within the ScrollView.

Actual Behavior

On Android, the content is truncated but the appropriate amount of space is still there.

Basic Information

  • Version with issue: 5.0.0
  • Last known good version: Unknown
  • Platform Target Frameworks:
    • Android: 5.1

Environment

Using latest VS 2019 with stable Xamarin 5.0

Build Logs

Not a build problem..

Screenshots

Top without image:
Screenshot_1610581530
Scrolled down (no image:
Screenshot_1610581503
Top with image:
Screenshot_1610581546
Scrolled down with image:
Screenshot_1610581549

Reproduction Link

Here's a github repository with the base VS 2019 project with the the main XAML modified to demonstrate the bug.

Workaround

Specify a height (via HeightRequest) and things work properly, but the Image size doesn't expand to the fill the space unless you get the height exactly right (and the native image height varies per platform).

@IMLizKing IMLizKing added s/unverified New report that has yet to be verified t/bug 🐛 labels Jan 13, 2021
@PureWeen
Copy link
Contributor

@IMLizKing can you attach a reproduction please? I'm not seeing what you're seeing by following your steps here

image

@PureWeen PureWeen added s/needs-info ❓ A question has been asked that requires an answer before work can continue on this issue. s/needs-repro ❔ This reported issue doesn't include a sample project reproducing the issue. Please provide one. labels Jan 22, 2021
@IMLizKing
Copy link
Author

Thanks for taking a look. I just made a github repository to demonstrate the bug and verified that it still fails for me on both my Pixel 4 (Android 11) and a Pixel 2 simulator running Android 10. Make sure you scroll down to see that the content is chopped off.

I will also note that if the image can load before the layout (or re-layout) is complete, so I've seen it fix itself when something else causes a re-layout. For example if I change the phone from dark to light mode (or vice versa) it reveals the truncated content (although this app doesn't handle the dark/light theme change properly). To me, this indicates that it's the time between initial layout and the actually loading of the image asynchronously that causes this issue.

@Redth Redth removed s/needs-info ❓ A question has been asked that requires an answer before work can continue on this issue. s/needs-repro ❔ This reported issue doesn't include a sample project reproducing the issue. Please provide one. labels Jan 25, 2021
@rmarinho rmarinho added e/6 🕕 6 and removed s/unverified New report that has yet to be verified labels Jan 28, 2021
@diegoserpa
Copy link

Same issue here. This happens when the ScrollView is the root element of the page. A workaround for this is wrap the ScrollView in a StackLayout, as seen #13307 and #12978.
The problem does not occur before v5.0.

@FirasAbdennadher
Copy link

Try to add stacklayout before scrollview

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

7 participants