OXO
OXO

Reputation: 1098

Platform specific HeightRequest

I tested my .NET MAUI App on iOS - Emulator and Pixel 5 - API 33 (Android 13.0 API 33). It seems like Android is displaying a little differently regarding how much space controls need.

Below a Frame I have a Button and it is like the space below the Button and the Frame is too small regarding what I want and how the look and feel in other Frames with Buttons is. On iOS it is looking good.

So, when increasing the HeightRequest for the Frame it doesn't look as good as before on iOS but looks good then on Android.

I could not set a platform specific HeightRequest as the compiler told it is not supported for HeightRequest.

How should I do it in XAML or is there only a way to set it in the Code-Behind then? Or are there even better ways to deal with this issue in general when switching between platforms?

Upvotes: 1

Views: 1106

Answers (1)

Liyun Zhang - MSFT
Liyun Zhang - MSFT

Reputation: 14574

You can do it in the xaml, such as:

<Frame>
   <Frame.HeightRequest>
      <OnPlatform x:TypeArguments="x:Double">
          <On Platform="Android" Value="50"/>
          <On Platform="iOS" Value="200"/>
      </OnPlatform>
   </Frame.HeightRequest>
</Frame>

Upvotes: 1

Related Questions