Skip to content
This repository was archived by the owner on Dec 27, 2024. It is now read-only.

Dimension Constraints

Nicolas Roard edited this page Dec 27, 2020 · 5 revisions

2.1 alpha 2

Optional layout_width & layout_height

We removed the need to declare android:layout_width and android:layout_height on the views; instead, they will by default be sized to WRAP_CONTENT, unless specified otherwise.

layout_constraintWidth and layout_constraintHeight

Those new attributes can be used as a replacement of android:layout_width and android:layout_height as well as several other ConstraintLayout attributes.

The different possibilities are:

  • dimension (e.g. 123dp)
  • match_parent
  • wrap_content
  • match_constraint (equivalent to 0dp with android:layout_width/height)
  • wrap_content_constrained (equivalent to wrap_content + constrainedWidth/Height=true with android:layout_width/height)
  • ratio=w:h or float
  • weight=float
  • parent=float (percent of parent)
Clone this wiki locally