简体   繁体   English

Xamarin.Forms中的性能问题

[英]Performance Issue in Xamarin.Forms

Is there any performance hit when we use any Expand (FillAndExpand, CenterAndExpand) attribute with any Layout (StackLayout or FlexLayout)? 当我们对任何布局(StackLayout或FlexLayout)使用任何Expand(FillAndExpand,CenterAndExpand)属性时,性能会受到影响吗? Any recommendation for how to use layout with considering the performance of the app. 有关如何考虑应用性能的布局建议。

From the official documentation: 从官方文档中:

Don't set the VerticalOptions and HorizontalOptions properties of a layout unless required. 除非需要,否则不要设置布局的VerticalOptions和Horizo​​ntalOptions属性。 The default values of LayoutOptions.Fill and LayoutOptions.FillAndExpand allow for the best layout optimization. LayoutOptions.Fill和LayoutOptions.FillAndExpand的默认值可实现最佳的布局优化。 Changing these properties has a cost and consumes memory, even when setting them to the default values. 即使将这些属性设置为默认值,更改这些属性也要付出代价并消耗内存。

And, 和,

When using a StackLayout, ensure that only one child is set to LayoutOptions.Expands. 使用StackLayout时,请确保LayoutOptions.Expands仅设置一个孩子。 This property ensures that the specified child will occupy the largest space that the StackLayout can give to it, and it is wasteful to perform these calculations more than once. 此属性确保指定的子项将占用StackLayout可以分配给它的最大空间,并且多次执行这些计算是浪费的。

So, having this in mind, try to simplify your layouts as possible, and only set Expand if it is really necessary. 因此,请牢记这一点,请尝试尽可能简化布局,仅在确实需要时才设置Expand。

You can read more information in Xamarin Performance Doc. 您可以在Xamarin Performance Doc中阅读更多信息

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM