This repository was archived by the owner on Dec 27, 2024. It is now read-only.
-
Couldn't load subscription status.
- Fork 172
XML to JSON and DSL for ConstraintSet attributes
Shane Wong edited this page Oct 5, 2022
·
23 revisions
XML for ConstraintSet has many attributes because of the way XML works. Many of them have been combined for example android:layout_width, layout_constraintWidth, layout_constrainedWidth, layout_constraintWidth_min, layout_constraintWidth_max, layout_constraintWidth_percent, and layout_constraintDimensionRatio are all combined in width:
{
width: 23,
width: 'spread',
width: { value: 'wrap', max: 300 }
}
| XML | JSON | DSL | Example (DSL) |
|---|---|---|---|
| android:orientation | 1* | ||
| android:id | 2* | createRefFor(...) | |
| android:visibility | visibility | visibility = | Visibility.kt |
| visibilityMode | N/A | ||
| android:alpha | alpha | alpha = | Visibility.kt |
| android:elevation | translationZ | ||
| android:rotation | rotationZ | rotationZ = | Transforms.kt |
| android:rotationX | rotationY | rotationY = | |
| android:rotationY | rotationX | rotationX = | Transforms.kt |
| android:scaleX | scaleX | scaleX = | CollapsibleToolbar.kt |
| android:scaleY | scaleY | scaleY = | CollapsibleToolbar.kt |
| pivotAnchor | TBD | ||
| android:transformPivotX | pivotX | pivotX = | Transforms.kt |
| android:transformPivotY | pivotY | pivotY = | |
| transformPivotTarget | TBD | ||
| android:translationX | translationX | translationX = | Transforms.kt |
| android:translationY | translationY | translationY = | Transforms.kt |
| android:translationZ | translationZ | translationZ = | Transforms.kt |
| android:layout_width | width | height = | |
| android:layout_height | height | height = | |
| layout_constraintWidth | width | width = | |
| layout_constraintHeight | height | height = | |
| android:layout_marginStart | start | start.linkTo() | |
| android:layout_marginBottom | bottom | bottom.linkTo() | |
| android:layout_marginTop | top | top.linkTo() | |
| android:layout_marginEnd | end | end.linkTo() | |
| android:layout_marginLeft | left | left.linkTo() | |
| android:layout_marginRight | right | right.linkTo() | |
| layout_constraintCircle | circular | circular() | test4.kt |
| layout_constraintCircleRadius | circular | circular() | test4.kt |
| layout_constraintCircleAngle | circular | circular() | test4.kt |
| layout_constraintGuide_begin | h/vGuideline | createGuidelineFromStart() createGuidelineFromTop() createGuidelineFromAbsoluteLeft() |
test.kt |
| layout_constraintGuide_end | h/vGuideline | createGuidelineFromEnd() createGuidelineFromBottom() createGuidelineFromAbsoluteRight() |
test.kt |
| layout_constraintRight_toLeftOf | right | right.linkTo() | |
| layout_constraintGuide_percent | h/vGuideline | createGuidelineFromStart() createGuidelineFromTop() createGuidelineFromAbsoluteLeft() createGuidelineFromEnd() createGuidelineFromBottom() createGuidelineFromAbsoluteRight() |
Guidelines.kt |
| layout_constraintLeft_toLeftOf | left | left.linkTo() | |
| layout_constraintLeft_toRightOf | left | left.linkTo() | |
| layout_constraintRight_toRightOf | left | right.linkTo() | |
| layout_constraintTop_toTopOf | top | top.linkTo() | |
| layout_constraintTop_toBottomOf | top | top.linkTo() | |
| layout_constraintBottom_toTopOf | bottom | bottom.linkTo() | |
| layout_constraintBottom_toBottomOf | bottom | bottom.linkTo() | |
| layout_constraintBaseline_toBaselineOf | baseline | baseline.linkTo() | |
| layout_constraintBaseline_toTopOf | baseline | baseline.linkTo() | |
| layout_constraintBaseline_toBottomOf | baseline | baseline.linkTo() | |
| layout_constraintStart_toEndOf | start | start.linkTo() | |
| layout_constraintStart_toStartOf | start | start.linkTo() | |
| layout_constraintEnd_toStartOf | end | end.linkTo() | |
| layout_constraintEnd_toEndOf | end | end.linkTo() | |
| layout_goneMarginLeft | left | left.linkTo()* | |
| layout_goneMarginTop | top | top.linkTo()* | |
| layout_goneMarginRight | right | right.linkTo()* | |
| layout_goneMarginBottom | bottom | bottom.linkTo()* | |
| layout_goneMarginStart | start | start.linkTo()* | |
| layout_goneMarginEnd | end | end.linkTo()* | |
| layout_goneMarginBaseline | baseline | baseline.linkTo()* | |
| layout_marginBaseline | baseline | baseline.linkTo()* | |
| layout_constrainedWidth | width | width = | |
| layout_constrainedHeight | height | height = | |
| layout_constraintHorizontal_bias | hBias | linkTo() | |
| layout_constraintVertical_bias | vBias | linkTo() | |
| layout_constraintWidth_default | width | width = | |
| layout_constraintHeight_default | height | height = | |
| layout_constraintWidth_min | width | width = | |
| layout_constraintWidth_max | width | width = | |
| layout_constraintWidth_percent | width | width = | |
| layout_constraintHeight_min | height | height = | |
| layout_constraintHeight_max | height | height = | |
| layout_constraintHeight_percent | height | height = | |
| layout_constraintDimensionRatio | height/width | width = Dimension.value(100.dp) height = Dimension.ratio("x:y") |
Ratio.kt |
| layout_constraintHorizontal_weight | ??? | horizontalChainWeight = | Chains.kt |
| layout_constraintVertical_weight | ??? | verticalChainWeight = | Chains.kt |
| layout_constraintHorizontal_chainStyle | hChain | createHorizontalChain() | Chains.kt |
| layout_constraintVertical_chainStyle | vChain | createVerticalChain() | Chains.kt |
| layout_wrapBehaviorInParent | ??? | ||
| barrierDirection | v/hBarrier* | createStartBarrier() createAbsoluteLeftBarrier() createTopBarrier() createEndBarrier() createAbsoluteRightBarrier() createBottomBarrier() |
Barriers.kt |
| barrierMargin | v/hBarrier* | createStartBarrier ... | |
| constraint_referenced_ids | (used in all helpers) | ||
| constraint_referenced_tags | |||
| android:maxHeight | height: { max: 300 } | ||
| android:maxWidth | width: { max: 300 } | ||
| android:minHeight | height: { min: 300 } | ||
| android:minWidth | width: { min: 300 } | ||
| barrierAllowsGoneWidgets | v/hBarrier* | createStartBarrier* | |
| chainUseRtl | Not implemented | createHorizontalChain() | |
| animateRelativeTo | MotionLayout* | ||
| animateCircleAngleTo | MotionLayout* | ||
| transitionEasing | MotionLayout* | ||
| pathMotionArc | MotionLayout* | ||
| polarRelativeTo | MotionLayout* | ||
| transitionPathRotate | MotionLayout* | ||
| drawPath | MotionLayout* | ||
| motionProgress | Not implemented | ||
| layout_constraintTag | code only | ||
| motionStagger | MotionLayout* | ||
| quantizeMotionSteps | MotionLayout* | ||
| quantizeMotionPhase | MotionLayout* | ||
| quantizeMotionInterpolator | MotionLayout* |
1* - By convention helpers will be explicitly vertical or horizontal (vBarrier or hBarrier)
2* - The id is usually the label
MotionLayout* - These features of MotionLayout are not implemented.
Helpers flow, barrier are not implemented