设置宽度以匹配ConstraintLayout中的约束 [英] Set width to match constraints in ConstraintLayout
问题描述
我想将视图的左右两侧限制在其父视图的空白处,并使其填充分配的空间.但是,将width设置为match_parent
或wrap_content
似乎会产生相同的结果.
I would like to constrain a View's left and right sides to it's parent view's margins and make it fill the allotted space. However, setting width to either match_parent
or wrap_content
appears to produce the same result.
是否有等同于match_constraints的东西(与match_parent和wrap_content相反)? match_parent
和wrap_content
是否会影响布局,还是在新的约束布局中将其忽略?
Is there something equivalent to match_constraints (as opposed to match_parent and wrap_content)? Do match_parent
and wrap_content
affect the layout or are they ignored in the new constraint layout?
在我最喜欢的平台上喜欢这个新的布局系统!
Loving this new layout system for my favorite platform!
推荐答案
match_parent
不支持.使用0dp
,您可以将约束视为可扩展的",而不是填补剩下的内容".
match_parent
is not supported. With 0dp
, you can think of your constraints as 'scalable' rather than 'filling whats left'.
此外,0dp
可以由一个位置定义,其中match_parent
依赖于其位置(x,y和宽度,高度)的父级
Also, 0dp
can be defined by a position, where match_parent
relies on it's parent for it's position (x,y and width, height)
这篇关于设置宽度以匹配ConstraintLayout中的约束的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!