Forum Xamarin.Forms
We are excited to announce that the Xamarin Forums are moving to the new Microsoft Q&A experience. Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

We encourage you to head over to Microsoft Q&A for .NET for posting new questions and get involved today.

ScrollView has height limitations built-in. Trying to insert very high image, it's being limited.

idchlifeidchlife Member ✭✭

Hello!

I'm creating several pages with very long images that basically has long "landing page"-like information about products.

Here is my layout:

  <ContentPage.Content>
    <ScrollView
      >

        <Image
          HorizontalOptions="FillAndExpand"
          VerticalOptions="FillAndExpand"
                    x:DataType="pages:ProductImagePage"
                    Source="{Binding ImageFilename, Converter={StaticResource ImageResourceConverter}}"
                />     
    </ScrollView>
  </ContentPage.Content>

One image has size: 1280 × 10620
and it fits perfectly!

Another one has size:

960 × 12234

And it's not showing properly: ScrollView somehow has height limit that I was not aware of, and this high image has paddings on the sides (which means Image encountered height limit and to maintain aspect ratio it lowered width of the image)

How to remove this ScrollView limit?

Best Answer

  • idchlifeidchlife Member ✭✭
    Accepted Answer

    @jezh unfortunately it does not do anything in my case. It seems my image is too long/high that ScrollView do create some limitations for image autosizer.

    As you can see in my OP post the problem does start with 960 × 12234 THIS size, but not 1280 × 10620 size. Which makes it's kinda clear that the problem not with aspect or something (since 2000 pixels height lower image renders perfectly, filling width of the screen nicely)

    In the end I just force assigned Image - HeightRequest value like 4700. It does not render beatifully on every phone and screen (sometimes sides margin is present sometimes not), but it does the job done, which is somewhat acceptable.

    The problem, though, persists. I will set this as accepted answer, but I presume people are struggling with same problem as my own without possibility to explain it clearly (it's hard to explain because all of answers over the internet people tried to point to aspect ratio, which does not help in this case), soooo, maybe I will create repro repository in some days for you to observe the problem.

Answers

  • jezhjezh Member, Xamarin Team Xamurai

    Well,for the Image control, there is a property Aspect for you to define how an image is displayed.
    A Aspect representing the scaling mode of the image. Default is AspectFit.

    When we check Aspect Enum,we will find:

  • idchlifeidchlife Member ✭✭
    Accepted Answer

    @jezh unfortunately it does not do anything in my case. It seems my image is too long/high that ScrollView do create some limitations for image autosizer.

    As you can see in my OP post the problem does start with 960 × 12234 THIS size, but not 1280 × 10620 size. Which makes it's kinda clear that the problem not with aspect or something (since 2000 pixels height lower image renders perfectly, filling width of the screen nicely)

    In the end I just force assigned Image - HeightRequest value like 4700. It does not render beatifully on every phone and screen (sometimes sides margin is present sometimes not), but it does the job done, which is somewhat acceptable.

    The problem, though, persists. I will set this as accepted answer, but I presume people are struggling with same problem as my own without possibility to explain it clearly (it's hard to explain because all of answers over the internet people tried to point to aspect ratio, which does not help in this case), soooo, maybe I will create repro repository in some days for you to observe the problem.

Sign In or Register to comment.