Android Studio布局编辑器ConstraintLayout:打包vs链 [英] Android Studio Layout Editor ConstraintLayout: pack vs chain

查看:407
本文介绍了Android Studio布局编辑器ConstraintLayout:打包vs链的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Android Studio布局编辑器中,我相对于ConstraintLayout看到单词"pack"和"chain".我知道它们都与将一条直线上的多个视图相互连接有关,但是它们之间的区别对我来说并不明显.

In the Android Studio Layout Editor I see the words "pack" and "chain" with respect to a ConstraintLayout. I know they both have something to do with multiple views being connected to each other in a line, but their difference is not clear to me.

包装"和链条"有什么区别?

What is the difference between "pack" and "chain"?

推荐答案

简短答案

Chain (链)是一组以垂直或水平线绑定在一起的视图. 打包表示应该将视图紧密地保持在一起,即彼此触摸(不包括任何填充).

Short answer

A Chain is a group of views that are bound together in a vertical or horizontal line. Pack means that the views should be kept very closely together, ie, touch each other (excluding any padding).

Pack表示视图紧密地包装在一起.想象一下,在旅行之前,您将衣服紧紧地装在行李箱中.

Pack means that the views are packed tightly together. Imagine that you are packing your clothes tightly together in a suitcase before going on a trip.

注意事项:

  • 您可以水平或垂直打包视图.
  • 打包本身并不会将视图彼此约束.

  • You can pack views horizontally or vertically.
  • Packing doesn't in itself doesn't constrain the views to each other.

  • 如果尚未链接,则打包将在布局编辑器"中移动其绝对位置,以使它们彼此相邻.
  • 如果将它们链接在一起,则将链接"模式设置为packed会将它们紧密地绑定在一起.

  • If they are not already chained, then packing moves their absolute position in the Layout Editor so that they are adjacent to each other.
  • If they are chained, then setting the Chain mode to packed binds them closely together.

app:layout_constraintHorizontal_chainStyle="packed"

当两个相邻的视图都彼此具有约束时,就会发生一条链.想象一下铁链.

A chain occurs when two adjacent views both have constraints to each other. Imagine an iron link chain.

文档很好地展示了这一点.

The documentation shows this well.

该链可以继续进行,其中链中的每个链接(视图)都具有到其邻居的双向链接.

This chain can continue where every link (view) in the chain has a two-way link to its neighbors.

连锁模式/风格

如上所述,链有不同的模式或样式.它们显示在(文档 ).

As I briefly mentioned above, there are different modes or styles for a chain. They are shown below (image from docs).

  1. 传播(默认)
  2. 向内传播
  3. 加权
  4. 包装

所有这些都是链接的. 已打包.

这篇关于Android Studio布局编辑器ConstraintLayout:打包vs链的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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