androidx.constraintlayout:constraintlayout
Official Description: ConstraintLayout for Android
CommonsWare’s Notes
ConstraintLayout
is the primary option nowadays for constructing an Android
UI, in terms of controlling where individual widgets are positioned on the screen
and how they are sized.
ConstraintLayout
is very flexible, allowing you to position widgets relative to:
- Each other
- The edges of the
ConstraintLayout
- Guidelines (invisible lines used solely for positioning rules)
- Barriers (guidelines tied to collections of widgets)
You can easily set a widget’s horizontal or vertical size to be wrap_content
(to be sized based on the widget’s contents) or 0dp
(to be stretched to fill
the space between two anchoring points along the requested axis).
Compared to legacy containers like LinearLayout
and RelativeLayout
,
ConstraintLayout
offers more functionality and (frequently) better performance.
Documentation
Knowledge
- Learn ConstraintLayout: ConstraintLayout Tutorial for Android (2019-04-05)
- Android ConstraintLayout explained using a complex UI (2019-03-03)
- ConstraintLayout in the LIMELIGHT (2018-12-19)
Samples
- Exploring Android: CommonsWare’s hands-on tutorial book builds a complete app from scratch, including using
ConstraintLayout
for the layouts - Sunflower: A gardening app illustrating Android development best practices with Android
Versions
- Latest Stable: 2.0.4
- Latest Release Candidate: 2.0.0-rc1
- Latest Beta: 2.0.0-beta8
- Latest Alpha: 2.1.0-alpha2