Monday, June 17, 2019

ConstraintLayout 2.0.0 beta 2

We are happy to announce the release of ConstraintLayout 2.0 beta 2. 

It’s available from the google maven repository:
dependencies {
    implementation 'com.android.support.constraint:constraint-layout:2.0.0-beta2'
}


or if using the AndroidX packages:
dependencies {
    implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta2'
}


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 Beta 2


Flow

New attributes were added to control the behavior of the last chain, in similar manner to flow_first* attributes:

flow_lastHorizontalStyle : spread|spread_inside|packed
flow_lastVerticalStyle : spread|spread_inside|packed
flow_lastVerticalBias : float
flow_lastHorizontalBias : float

MotionLayout

APIs additions

  • MotionLayout.TransitionListener no longer has the method allowsTransition. This was replaced with the MotionScene.Transition.setEnable
  • Added APIs to construct a MotionScene and Transition programmatically and manipulate them.

Transition ID

You can now name transitions with an ID using the attribute

MotionScene.Transition MotionLayout.getTransition(int id)


<Transition
      android:id="@id/tobigsceen" ...

Transition Disable

Now you can disable and enable Transitions in XML and programmatically. A <Transition> now has an attribute transitionDisable. You can also enable or disable them programmatically with Transition.setEnable(true) and query with Transition.isEnabled().

Important: This replaces the callback “allowsTransition” in the interface MotionLayout.TransitionListener

View Velocity

public void getViewVelocity(View view, float posOnViewX, float posOnViewY, float[] returnVelocity, int type) {

Accessing the Velocity of an animating view. You can get the velocity a view is moving at.
It takes the coordinate on the view and returns the velocity of the view.
There are 4 types of velocities it can return. It can return static or dynamic, pre or post layout.

The static velocity does not incorporate the actual motion driven by touch.


public final static int VELOCITY_POST_LAYOUT = 0;
public final static int VELOCITY_LAYOUT = 1;
public final static int VELOCITY_STATIC_POST_LAYOUT = 2;
public final static int VELOCITY_STATIC_LAYOUT = 3;

To aid in understanding how to use it, we have included a utility view MotionTelltales based on MockView but showing the velocity of 25 points on the view.




Key Trigger redirection


Now a KeyTrigger can trigger a method on another view using the attribute triggerReceiver.

<KeyTrigger
     motion:triggerReceiver="@+id/view" ...

Bugfixes


Several issues where fixed in beta 2:


Motion Layout nested scrolling issue133624931
Alpha 4 Layout Weights not working properly130580479
ConstraintLayout does not respect minHeight with wrap_content130437914
[MotionLayout] getProgress() Value Gets Reset When The Container Layout Animates.112521093
[MotionLayout] Fragments in ViewPager sometimes are not drawn123379505
MotionLayout animation does not work inside fragment122929956
ConstraintLayout:2.0.0-alpha4 no longer preserves view scaling properly with MotionLayout130115829
Child view not centered when ConstraintLayout size changes133273843
[ConstraintLayout 2.0.0-alpha5] Regression in MotionLayout when scrolling a scrollable view131572132
Height of nested constraint layout child not measured correctly in ConstraintLayout 2.0.0-alpha4+ (including beta1)133202039
[ConstraintLayout 2.0.0-alpha5] Regression in MotionLayout modifying a ConstraintSet131874827
Constrain Layout 2.0.0 Alpha 4 to Beta 1134841040
Flow verticalAlign="baseline" not working134533710
ConstraintLayout Group and Barrier is not working in dynamic feature module.133032779
ConstraintLayout:2.0.0-alpha4 MotionLayout does not respect parent padding130561744
app:showPaths crashes on transition with a duration smaller than 16 ms134086361
PlaceHolder doesn't display132951221
[MotionLayout] Migrate MotionLayout to NestledScrolling3 and override functionality128914828
Maybe useless code in MotionLayout class131532235
Placeholder emptyVisibility attribute is incorrect131747094
Barrier is ignored132651309
Request to programmatically change autoTransition132878306
Handle Snackbar + FAB with MotionLayout133541548
Problem when trying to wrap chains of width-constrained views134137982
MotionLayout animating incorrectly when used in a recyclerview118289003
Animatinos in recyclerview end in unexpected states118289936
TextView is clipped when using nested ConstraintLayouts and constraintDimensionRatio134082517
android:gravity does not work as expected in ConstraintLayout 2.0.0-alpha4+ (including beta1)132651320
2.0 B1 bug / changed behavior133465553
ConstraintLayout does not measure height correctly when using wrap_content and layout_constrainedHeight is set to true.132314169
ConstraintLayout will not wrap TextView to the correct height when using wrap_content and app:layout_constrainedHeight="true"123551995
Buttons in Flow has text aligned to left (and alignment behaves strange)133809201
adding constarint from kotlin is not respected in beta , works fine in alpha2 version133184664
When the View referenced by Flow has a child View, the layout is wrong.133092993
Flow does not work well with 0dp133326448
MotionLayout not triggering animation after scrolling a list122676392
Setting MotionScene in code to MotionLayout (Not working same as if we set layoutDescription in MotionLayout in xml)116674308
Allow KeyTrigger to call methods on a different view132457332
Constraint not respected when using the ID of the parent instead of `parent` in XML.133201550