android / views-widgets-samples

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

Found bug in measurement logic #71

Open OleksandrKucherenko opened 7 years ago

OleksandrKucherenko commented 7 years ago
    <!-- Root -->
    <android.support.constraint.ConstraintLayout
        android:id="@+id/fl_bottom_bar_container"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        >

        <!-- Toolbar area: 85% -->
        <android.support.constraint.Guideline
            android:id="@+id/guideline_top"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:orientation="horizontal"
            app:layout_constraintGuide_percent=".85"
            />

        <View
            android:layout_width="0dp"
            android:layout_height="0dp"
            android:background="@color/ep_pink"
            app:layout_constraintTop_toTopOf="@+id/guideline_top"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintDimensionRatio="w,1:1"
            app:layout_constraintLeft_toLeftOf="parent"
            app:layout_constraintRight_toRightOf="parent"
            />

    </android.support.constraint.ConstraintLayout>

Expected:

Reality:

Potentially there are several problems:

410063005 commented 7 years ago

image There seems to be no problem

OleksandrKucherenko commented 7 years ago

In IDE it displayed correctly, but on device it fails.

OleksandrKucherenko commented 7 years ago

instead of View use a custom view, and in it trace calls of onMeasure and it parameters. Problem is easy to reproduce.

<View
            android:layout_width="0dp"
            android:layout_height="0dp"
            android:background="@color/ep_pink"
            app:layout_constraintTop_toTopOf="@+id/guideline_top"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintDimensionRatio="w,1:1"
            app:layout_constraintLeft_toLeftOf="parent"
            app:layout_constraintRight_toRightOf="parent"
            />