Movatterモバイル変換


[0]ホーム

URL:


Skip to main content

This browser is no longer supported.

Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.

Download Microsoft EdgeMore info about Internet Explorer and Microsoft Edge
Table of contentsExit editor mode

Xamarin.Forms Fast Renderers

Feedback

In this article

Traditionally, most of the original control renderers on Android are composed of two views:

  • A native control, such as aButton orTextView.
  • A containerViewGroup that handles some of the layout work, gesture handling, and other tasks.

However, this approach has a performance implication in that two views are created for each logical control, which results in a more complex visual tree that requires more memory, and more processing to render on screen.

Fast renderers reduce the inflation and rendering costs of a Xamarin.Forms control into a single view. Therefore, instead of creating two views and adding them to the view tree, only one is created. This improves performance by creating fewer objects, which in turn means a less complex view tree, and less memory use (which also results in fewer garbage collection pauses).

Fast renderers are available for the following controls in Xamarin.Forms on Android:

Functionally, these fast renderers are no different to the legacy renderers. From Xamarin.Forms 4.0 onwards, all applications targetingFormsAppCompatActivity will use these fast renderers by default. Renderers for all new controls, includingImageButton andCollectionView, use the fast renderer approach.

Performance improvements when using fast renderers will vary for each application, depending upon the complexity of the layout. For example, performance improvements of x2 are possible when scrolling through aListView containing thousands of rows of data, where the cells in each row are made of controls that use fast renderers, which results in visibly smoother scrolling.

Note

Custom renderers can be created for fast renderers using the same approach as used for the legacy renderers. For more information, seeCustom Renderers.

Backwards compatibility

Fast renderers can be overridden with the following approaches:

  1. Enabling the legacy renderers by adding the following line of code to yourMainActivity class before callingForms.Init:

    Forms.SetFlags("UseLegacyRenderers");
  2. Using custom renderers that target the legacy renderers. Any existing custom renderers will continue to function with the legacy renderers.

  3. Specifying a differentView.Visual, such asMaterial, that uses different renderers. For more information about Material Visual, seeXamarin.Forms Material Visual.

Related links


  • Last updated on

In this article