What is ConstraintLayout Optimizer?

后端 未结 1 964
长发绾君心
长发绾君心 2021-02-12 14:30

Google published ConstraintLayout 1.1.0 beta 6 on March 22, 2018. It has a new constraint known as Optimizer. The documentation of Opt

1条回答
  •  执笔经年
    2021-02-12 14:52

    Constraint Layout 1.1 adds several new optimizations that speed up your layouts. The optimizations run as a separate pass, and attempt to reduce the number of constraints needed to layout your views.

    In general they work by finding constants in your layout and simplifying them.

    There’s a new tag, called layout_optimizationLevel, which configures the optimization level. It can be set to the following:

    • barriers figures out where barriers are and replaces them with simpler constraints
    • direct optimizes elements directly connected to fixed element, for example the side of the screen or guidelines, and continues to optimize any elements directly connected to them
    • standard is the default optimization level which includes barriers and direct
    • dimensions is currently experimental and can cause issues on some layouts — it optimizes the layout pass by calculating dimensions
    • chains is currently experimental and figures out how to lay out chains of elements with fixed sizes.

    If you want to try out the experimental optimizations dimensions and chains you can enable them on a ConstraintLayout with

    Note: To clear whole concept, you must have to implement this.

    0 讨论(0)
提交回复
热议问题