8 votes

Problème de mise en page de la contrainte java.lang.AssertionError : TOP

J'ai commencé à utiliser Constraint Layout, je rencontre une erreur d'assertion lors de la compilation du fichier de conception. Quelle est la bonne façon de résoudre ce problème ? Je me suis trompé de jour. Voici ma conception XML.

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/cL_Layout"
    android:layout_width="match_parent"
    android:layout_height="80dp"
    android:background="@color/card_background">

    <android.support.constraint.Guideline
        android:id="@+id/gL_right_margin"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        app:layout_constraintGuide_percent="0.95" />

    <android.support.constraint.Guideline
        android:id="@+id/gL_vertical_center"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        app:layout_constraintGuide_percent="0.50364965" />
    <android.support.constraint.Guideline
        android:id="@+id/gL_bottom_margin"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        app:layout_constraintGuide_percent="1.0" />

    <android.support.constraint.Guideline
        android:id="@+id/gL_image_size_margin"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        app:layout_constraintGuide_percent="0.3" />

    <ImageView
        android:id="@+id/imgVw_AddClips_recVw_icon"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:layout_marginBottom="4dp"
        android:layout_marginStart="4dp"
        android:layout_marginTop="4dp"
        android:adjustViewBounds="true"
        android:background="@drawable/qik_highlights_shape"
        android:contentDescription="@string/dummy_content"
        android:scaleType="fitCenter"
        android:src="@drawable/bg_cloud_icon"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toStartOf="@+id/gL_image_size_margin"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <com.ibot.cyranoapp.customview.TextViewFont
        android:id="@+id/txtIp_recVw_AddClips_Name_title"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_alignParentStart="true"
        android:layout_marginStart="8dp"
        android:layout_marginTop="8dp"
        android:text="@string/recVw_Template_channel"
        android:textAllCaps="false"
        android:textColor="@color/fa_preview_button_text_grey"
        android:textSize="14sp"
        android:textStyle="bold"
        app:layout_constraintStart_toEndOf="@+id/gL_image_size_margin"
        app:layout_constraintTop_toTopOf="parent" />

    <com.ibot.cyranoapp.customview.TextViewFont
        android:id="@+id/txtIp_recVw_Components_Name_title"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_alignParentStart="true"
        android:layout_marginStart="8dp"
        android:text="@string/recVw_Template_Components"
        android:textAllCaps="false"
        android:textColor="@color/fa_preview_button_text_grey"
        android:textSize="12sp"
        app:layout_constraintStart_toEndOf="@+id/gL_image_size_margin"
        app:layout_constraintTop_toBottomOf="@+id/txtIp_recVw_AddClips_Name_title" />

    <com.ibot.cyranoapp.customview.TextViewFont
        android:id="@+id/txtIp_recVw_channel_subscribers_hint"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginStart="8dp"
        android:text="@string/channel_subscribers"
        android:textAllCaps="false"
        android:textColor="@color/fa_preview_button_text_grey"
        android:textSize="12sp"
        app:layout_constraintStart_toEndOf="@+id/gL_image_size_margin"
        app:layout_constraintTop_toBottomOf="@+id/txtIp_recVw_Components_Name_title" />

    <RadioButton
        android:id="@+id/rBtn_AddClips_SelectionIcon"
        android:layout_width="20dp"
        android:layout_height="20dp"
        android:layout_marginBottom="8dp"
        android:layout_marginTop="8dp"
        android:button="@drawable/qik_checkbox"
        android:text="@null"
        android:theme="@null"
        app:layout_constraintBottom_toTopOf="@+id/gL_bottom_margin"
        app:layout_constraintEnd_toStartOf="@+id/gL_right_margin"
        app:layout_constraintTop_toTopOf="parent" />

    <View
        android:id="@+id/view_template_1"
        android:layout_width="match_parent"
        android:layout_height="1dp"
        android:background="@color/fa_preview_button_text_grey"
        android:visibility="gone"
        app:layout_constraintBottom_toTopOf="@+id/gL_right_margin"
        app:layout_constraintEnd_toEndOf="@+id/gL_right_margin" />

    <View
        android:id="@+id/view_template_selection"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:background="@color/fa_green_1"
        app:layout_constraintBottom_toBottomOf="@+id/view_template_1"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />
</android.support.constraint.ConstraintLayout>

Et mon journal d'erreurs ici :

java.lang.AssertionError : TOP at Android.support.constraint.solver.widgets.Guideline.getAnchor(Guideline.java:159) at Android.support.constraint.solver.widgets.ConstraintWidget.immediateConnect(ConstraintWidget.java:1597) at Android.support.constraint.ConstraintLayout.setChildrenConstraints(ConstraintLayout.java:1031) at Android.support.constraint.ConstraintLayout.updateHierarchy(ConstraintLayout.java:794) at Android.support.constraint.ConstraintLayout.onMeasure(ConstraintLayout.java:1542) at Andro at Android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6459) at Android.widget.FrameLayout.onMeasure(Frame at Android.support.v7.widget.ContentFrameLayout.onMeasure(ContentFrameLayout.java:141) at Android.view.View.measure(View.java:21051) at Android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6459) at Android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1464) at Android.widget.LinearLayout.measureVertical(LinearLayout.java:758) at Android.widget.LinearLayout.onMeasure(LinearLayout.java:640) at Android.view.View.measure(View.java:21051) at Android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6459) at Android.widget.FrameLayout.onMeasure(FrameLayout.java:185) at Android.view.View.measure(View.java:21051) at Android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6459) at Android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1464) at Android.widget.LinearLayout.measureVertical(LinearLayout.java:758) at Android.widget.LinearLayout at Android.view.View.measure(View.java:21051) at Android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6459) at Android.widget.FrameLayout.onMeasure(FrameLayout.java:185) at com.Android.internal.policy.DecorView.onMeasure(DecorView. at Android.view.View.measure(View.java:21051) at Android.view.ViewRootImpl.performMeasure(ViewRoot at Android.view.ViewRootImpl.measureHierarchy(ViewRootImp at Android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1893) at Android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1522) at Android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:7098) at Android.view.Choreographer$CallbackRecord.run(Choreogra at Android.view.Choreographer.doCallbacks(Choreographer.java:702) a at Android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:913) at Android.os.Handler.handleCallback at Android.os.Handler.dispatchMessage at Android.os.Looper.loop(Looper.java:154) at Android.app.ActivityThread.main(ActivityThr at java.lang.reflect.Method.invoke(Nat at com.Android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1520) at com.Android.internal.os.ZygoteInit.main(ZygoteInit.java:1410)

11voto

Belbahar Raouf Points 525

Lorsque vous utilisez une ligne directrice verticale, toute vue qui y est contrainte doit l'être horizontalement, et il en va de même pour les lignes directrices horizontales.

Dans votre cas, vous contraignez view_template_1 verticalement à une ligne directrice verticale, modifiez donc ce :

app:layout_constraintBottom_toTopOf="@+id/gL_right_margin"

par une ligne directrice horizontale

Vérifiez toujours vos mises en page et assurez-vous que vous ajoutez la contrainte appropriée à une ligne directrice.

1voto

Yoric Points 202

Essayez de supprimer le symbole "plus" du référencement de vos lignes directrices. Par exemple app:layout_constraintEnd_toStartOf="@+id/gL_image_size_margin"

Prograide.com

Prograide est une communauté de développeurs qui cherche à élargir la connaissance de la programmation au-delà de l'anglais.
Pour cela nous avons les plus grands doutes résolus en français et vous pouvez aussi poser vos propres questions ou résoudre celles des autres.

Powered by:

X