什么是ConstraintLayout Optimizer? [英] What is ConstraintLayout Optimizer?

查看:151
本文介绍了什么是ConstraintLayout Optimizer?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Google于2018年3月22日发布了 ConstraintLayout 1.1.0 beta 6 .它具有一个新的约束,称为 Optimizer . https://developer.android.com/上的Optimizer文档reference/android/support/constraint/ConstraintLayout.html#Optimizer 没有提及何时使用以及为什么使用它.有人可以阐明它的用法吗?

Google published ConstraintLayout 1.1.0 beta 6 on March 22, 2018. It has a new constraint known as Optimizer. The documentation of Optimizer at https://developer.android.com/reference/android/support/constraint/ConstraintLayout.html#Optimizer does not mention when to use and why to use it. Can someone shed some light about it usage.

推荐答案

约束布局1.1添加了一些新的优化方法,可以加快布局速度.这些优化作为单独的过程运行,并尝试减少布局视图所需的约束数量.

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.

有一个名为layout_optimizationLevel的新标签,用于配置优化级别.可以将其设置为以下内容:

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

  • 障碍找出障碍的位置,并用更简单的约束代替
  • 直接优化直接连接到固定元素的元素,例如屏幕的侧面或辅助线,并继续优化直接连接到固定元素的任何元素
  • 默认设置为
  • standard ,其中包括障碍直接
  • 尺寸目前处于实验阶段,可能会在某些布局上引起问题issues-它通过计算尺寸来优化布局遍历
  • 目前处于实验阶段,可以弄清楚如何布置固定大小的元素链.
  • 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.

如果您想尝试实验性的优化尺寸和链,可以在ConstraintLayout上启用它们,

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

<android.support.constraint.ConstraintLayout 
    app:layout_optimizationLevel="standard|dimensions|chains"

注意:要清除整个概念,您必须执行此操作.

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

这篇关于什么是ConstraintLayout Optimizer?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆