英文:
Platform specific HeightRequest
问题
在iOS模拟器和**Pixel 5 - API 33 (Android 13.0 API 33)**上测试了我的.NET MAUI应用程序。似乎Android在控件所需空间方面显示略有不同。
在一个框架下面我有一个按钮,似乎按钮下面的空间和框架相比太小了,不符合我想要的样子,也不像其他带有按钮的框架那样。在iOS上看起来很好。
因此,当增加框架的HeightRequest时,它在iOS上看起来就不那么好了,但在Android上看起来不错。
我无法为HeightRequest设置特定于平台的设置,因为编译器告诉我不支持HeightRequest。
在XAML中应该如何做,或者只有在Code-Behind中设置它的方法吗?或者在在平台之间切换时,是否有更好的解决此问题的方法?
英文:
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?
答案1
得分: 0
你可以在XAML中完成,例如:
<Frame>
<Frame.HeightRequest>
<OnPlatform x:TypeArguments="x:Double">
<On Platform="Android" Value="50"/>
<On Platform="iOS" Value="200"/>
</OnPlatform>
</Frame.HeightRequest>
</Frame>
英文:
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>
</details>
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论