Skip to content
This repository was archived by the owner on Dec 27, 2024. It is now read-only.
Nicolas Roard edited this page Jun 11, 2021 · 2 revisions

ConstraintSet can be initialized from a JSON string:

 { g1: { type: 'vGuideline', start: 80 }, button: { top: ['title', 'bottom', 16], start: ['g1', 'start'] }, title: { centerVertically: 'parent', start: ['g1', 'start'] } } 

Is the equivalent to the Kotlin DSL:

 ConstraintSet { val button = createRefFor("button") val title = createRefFor("title") val g1 = createGuidelineFromStart(80.dp) constrain(button) { top.linkTo(title.bottom, 16.dp) start.linkTo(g1) } constrain(title) { centerVerticallyTo(parent) start.linkTo(g1) } }, 

The overall syntax is as follow:

 <id> : { <constraints> } 

With following the pattern:

 <from anchor> : [ '<target id>', '<target anchor>', <margin> ] 

Clone this wiki locally