We just released ConstraintLayout 2.0.0 alpha 4. It’s available from the google maven repository:
dependencies {
implementation 'com.android.support.constraint:constraint-layout:2.0.0-alpha4'
}
or if using the AndroidX packages:
dependencies {
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-alpha4'
}
Documentation is available on https://developer.android.com/reference/android/support/constraint/classes.html
Changes
This release contains various bug fixes and performance improvements:
ConstraintLayout
- Dynamic feature modules fix when using barriers and helpers
- Chain fixes (bias with gone elements, RTL fixes)
- Barrier fixes (RTL behavior, now can use a margin on a Barrier)
- match_constraints fixes (max support, bias, percent…)
- setTag/getTag on Group was fixed
- ConstraintSet::setGoneMargin() for Top/Bottom
- baseline behavior on gone
- wrap behavior fixes
MotionLayout
- Visibility fixes
- Flickering issues / jump issues fixed
- Various match_constraints issues fixed
- Custom color interpolation (alpha was incorrectly handled)
- Better barrier / helpers support
New Features
We also added several new features to MotionLayout:
- Richer behaviors for OnClick actions
- CustomAttributes support for customPixelDimensions
- ImageFilterView overlay support
- KeyTrigger collision support
- Attributes rename
OnClick
OnClick now supports a richer set of behaviours
- Toggle - animate back and forth ( = transitionToEnd|transitionToStart)
- transitionToEnd - animate to the end state
- transitionToStart - animate to the start state
- jumpToEnd - Jump to the end state
- jumpToStart - Jump to the start state
These can be combined to allow jumping to the end but smooth transition to the start.
<OnClick motion:targetId="@id/button_west"
motion:clickAction="transitionToEnd|transitionToStart"/>
<OnClick motion:targetId="@id/button_south"
motion:clickAction="jumpToStart|transitionToEnd"/>
|
CustomPixelDimensions
Used when the method takes pixels such as setTextSize(...)
<CustomAttribute
motion:attributeName="textSize"
motion:customPixelDimension="2dp" />
|
ImageFilterView
New tag overlay - true(default) / false affects crossfade behaviour set to false to crossfade transparent objects.
KeyTrigger collision support
You can fire a KeyTrigger on collision with another view.
<KeyTrigger
motion:motionTarget="@id/button"
motion:motion_triggerOnCollision ="@id/button2"
motion:onPositiveCross="callOnClick"
motion:motion_postLayoutCollision="true"
/>
|
- motion_triggerOnCollision - Id of view to check collision with
- motion_postLayoutCollision tested including layout or layout+transform
- onPositiveCross Trigger on entering collision state
- onNegativeCross Trigger on leaving the collision state
- onCross Trigger on entering or leaving the collision state
Rename
To minimize the chance of name clashes with 3p libraries we have renamed attributes that were clashing or had a good chance of clashing.
Old
|
New
|
<OnClick
app:mode="toggle"
app:target="@+id/button" />
|
<OnClick
app:clickAction="toggle"
app:targetId="@+id/button" />
|
<Transition
motion:constraintSetStart="@+id/start"
motion:constraintSetEnd="@+id/end"
motion:nterpolator="easeIn"
motion:duration="1000">
|
<Transition
motion:constraintSetStart="@+id/start"
motion:constraintSetEnd="@+id/end"
motion:motionInterpolator="easeIn"
motion:duration="1000">
|
motion:duration="123"
|
motion:defaultDuration="123"
|
motion:interpolator="easeInOut"
|
motion:motionInterpolator="easeInOut"
|
motion:progress="0.3"
|
motion:motionProgress="0.3"
|
In <OnClick>
motion:target="@+id/button"
|
In <OnClick>
motion:targetId="@+id/button"
|
In <Key* motion:target="0.3"
|
In <Key*
motion:motionTarget="0.3"
|
motion:elevation="0.3"
motion:rotation="0.3"
motion:rotationX="0.3"
motion:rotationY="0.3"
motion:scaleX="0.3"
motion:scaleY="0.3"
motion:transformPivotX="0.3"
motion:transformPivotY="0.3"
motion:translationX="0.3"
motion:translationY="0.3"
motion:translationZ="0.3"
|
android:elevation="0.3"
android:rotation="0.3"
android:rotationX="0.3"
android:rotationY="0.3"
android:scaleX="0.3"
android:scaleY="0.3"
android:transformPivotX="0.3"
android:transformPivotY="0.3"
android:translationX="0.3"
android:translationY="0.3"
android:translationZ="0.3"
|
motion:transitionPathRotate="0.3"
|
motion:motionPathRotate="0.3"
|