Exploring Constraint Layout in JetPack Compose
Develop in Jetpack Compose with me
Introduction
These days JetPack-compose is evolving rapidly; one of the significant developments I’ve observed recently is constraint-layout in compose. Constraint layout is a compelling component, even in our traditional UI design (XML). So I thought of giving it a try to use in compose.
Constraint layout brought many advanced and powerful features to design UI. For starters, it’s a combination of traditional RelativeLayout
and LinearLayout
. We can also design a responsive layout with guidelines, barriers, chains and more.
The way constraint layout works in compose is similar to use it in the classic Android traditional view system. In compose, a ConstraintLayout requires a ConstraintSet as an argument. In which we’ve to place all the constraints of the layout. Children block contains the child’s of the layout.
Things to Remember
ConstraintSet
As compose is an entirely different approach to design UI, likewise using constraint layout. As I said, we need to use constraintSet
argument to mention all the constraints in the layout using tags.