We are happy to announce the release of ConstraintLayout 2.0 beta 1. APIs are now considered stable for the remaining of the 2.0 release cycle.
It’s available from the google maven repository:
dependencies {
implementation 'com.android.support.constraint:constraint-layout:2.0.0-beta1'
}
or if using the AndroidX packages:
dependencies {
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta1'
}
Documentation is available on https://developer.android.com/reference/android/support/constraint/classes.html
Examples are available on
https://github.com/googlesamples/android-ConstraintLayoutExamples
New in Beta1
Flow virtual layout
- bug fixes (padding behavior + wrap content behavior)
- addition of addView()/removeView() on ConstraintHelper, allowing runtime addition/removal of refrenced views
MotionLayout
Enhanced Staggered API
Previously staggered had just one attributes in
<Transition>: staggered=”float”. It would stagger the animation transition of all objects based on their Manhattan distance from the top left corner.
You can now define in a ConstraintSet:
The views animation duration = duration * (1 - stagger)
The view starts animating at duration * (stagger - stagger * (S(Vi) - S(V0)) / (S(Vn) - S(V0)))
OnSwipe onTouchUp Modes
We changed removed the attribute “autoComplete” and changed to onTouchUp
motion:onTouchUp=”mode"onTouchUp has the following modes:
- autoComplete - normal default behavior
- autoCompleteToStart - same as normal engine but always goes to start.
- autoCompleteToEnd - same as normal engine but always goes to start.
- stop - stop where you are
- decelerate - linear drop in velocity allowing hitting the start or end with velocity
- decelerateAndComplete - like decelerate but if insufficient velocity to end switch to autoComplete
motion:onTouchUp="decelerateAndComplete"
|
visibilityMode
We added the ability to ignore the visibility of a view. This allows the applications to control the visibility and not have MotionLayout set it.
motion:visibilityMode="ignore"
|
TransitionListener Callback interface change
One new API was added to the callback to allow you to programmatically block a transition.
public interface TransitionListener {
public void onTransitionStarted(MotionLayout motionLayout,
int startId, int endId);
void onTransitionChange(MotionLayout motionLayout,
int startId, int endId,
float progress);
void onTransitionCompleted(MotionLayout motionLayout, int currentId);
public void onTransitionTrigger(MotionLayout motionLayout, int triggerId, boolean positive,
float progress);
boolean allowsTransition(MotionScene.Transition transition);
}
|
Attribute changes
In general we adopted a policy that if there is an android attribute we use it.
Old
|
new
|
app:layout_width
app:layout_height
app:layout_marginStart
app:layout_marginBottom
app:layout_marginTop
app:layout_marginEnd
app:layout_marginLeft
app:layout_marginRight
app:visibility
app:alpha
|
android:layout_width
android:layout_height
android:layout_marginBottom
android:layout_marginBottom
android:layout_marginTop
android:layout_marginEnd
android:layout_marginLeft
android:layout_marginRight
android:visibility
android:alpha
|