dotnet / dotnet/maui

[iOS] Image.HeightRequest not respected when Image added in an Horizontal StackLayout

Open
#12,879 5 comments 2 reactions 0 assignees View on GitHub
area-controls-image layout-stack platform/ios s/triaged s/verified t/bug
Dominant language
C#
Stars
23.3k
Forks
2k
Avg merge
1d 14h
Merged PRs (30d)
296

Description

### Description

Adding an `Image` in an horizontal `StackLayout` and setting the Image's `HeightRequest` to
something different than the underlying image Height is rendered differently on iOS and Android.

On iOS, Image in an horizontal StackLayout does not respect HeightRequest and always shows
the image with its original size.

On Android, the Image is scaled correctly with regard to the HeightRequest property.

This is not an issue when using vertical `StackLayout` or `Grid`.

### Steps to Reproduce

* Create a `StackLayout` with Horizontal orientation
* Add an `Image` children to the StackLayout and set its `HeightRequest` to something else
than its original height.

OR

Run the attached sample on iOS and Android and compare the rendered views. (See screenshots below)

![Screenshot showing expected result on Android, Image is scaling](https://github.com/durandt/maui-issue4-ios-image-in-horizontal-stack-layout/raw/main/maui-issue4-android.png) ![Screenshot showing unexpected result on iOS, Image is NOT scaling](https://github.com/durandt/maui-issue4-ios-image-in-horizontal-stack-layout/raw/main/maui-issue4-ios.png)

### Link to public reproduction project repository

https://github.com/durandt/maui-issue4-ios-image-in-horizontal-stack-layout

### Version with bug

7.0 (current)

### Last version that worked well

Unknown/Other

### Affected platforms

iOS

### Affected platform versions

iOS16.2

### Did you find any workaround?

Avoid wrapping Images in horizontal StackLayouts

### Relevant log output

_No response_

Contributor guide

Open the contributing guide

Research direction

Start with the linked reproduction project and run it on iOS and Android, comparing the Image inside a horizontal StackLayout with its HeightRequest set differently from the source image height. Trace the iOS layout behavior responsible for sizing the Image; done means the iOS rendering respects HeightRequest like Android without regressing vertical StackLayout or Grid behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, ios
Domain
frontend, mobile
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.