android / views-widgets-samples

Multiple samples showing the best practices in views-widgets on Android.
Apache License 2.0
5.03k stars 3.01k forks source link

MotionLayout: unnecessary child measure #168

Open igor-alyoshin opened 3 years ago

igor-alyoshin commented 3 years ago

Hi. MotionLayout needs a little optimization. I have child view with fixed height (for example 1599px) When I moving it out of screen child height resized to 1598px and measure called. It happens when child start out of screen.

Mistake in: Class: androidx.constraintlayout.motion.widget.MotionPaths.java Method: void setView(View view, int[] toUse, double[] data, double[] slope, double[] cycle)

v_height = 1599.0 v_y = -0.91099477

    l = (int)(0.5F + v_x);
    int t = (int)(0.5F + v_y);
    int r = (int)(0.5F + v_x + v_width);
    int b = (int)(0.5F + v_y + v_height);
    int i_width = r - l;
    int i_height = b - t;
    boolean remeasure = i_width != view.getWidth() || i_height != view.getHeight();

t = 0 b = 1598.0 remeasure = true

Same issue when v_x gets less than 0