Why is the error "This view is not constrained ..." in Constraintlayout?

Asked

Viewed 7,071 times

3

What is the reason for this mistake?

This view is not constrained, it only has designtime positions, so it will jump to (0,0) unless you add constraints

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:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.pedrogouveia.myapplication.MainActivity">

    <TextView
        android:id="@+id/textView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:autoSizeStepGranularity="?android:attr/dialogPreferredPadding"
        android:text="SIGN UP"
        android:textColor="#54C571"
        android:textSize="25dp"
        tools:layout_editor_absoluteX="16dp"
        tools:layout_editor_absoluteY="16dp" />

    <EditText
        android:id="@+id/Primeiro Nome"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:ems="10"
        android:inputType="textPersonName"
        android:text="Primeiro Nome"
        tools:layout_editor_absoluteX="16dp"
        tools:layout_editor_absoluteY="97dp" />

    <EditText
        android:id="@+id/editText2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:ems="10"
        android:inputType="textPersonName"
        android:text="Apelido"
        tools:layout_editor_absoluteX="16dp"
        tools:layout_editor_absoluteY="178dp" />

    <EditText
        android:id="@+id/editText3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:ems="10"
        android:inputType="textEmailAddress"
        android:text="e-mail"
        tools:layout_editor_absoluteX="16dp"
        tools:layout_editor_absoluteY="261dp" />

    <EditText
        android:id="@+id/editText4"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:ems="10"
        android:inputType="textPassword"
        android:text="password"
        tools:layout_editor_absoluteX="16dp"
        tools:layout_editor_absoluteY="347dp" />

    <Button
        android:id="@+id/button"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Button"
        tools:layout_editor_absoluteX="266dp"
        tools:layout_editor_absoluteY="411dp" />
</android.support.constraint.ConstraintLayout>
  • 1

    @Pedrogouveia , if the processor complained about it, it means that there was no syntactic error, only this semantic alert

  • Did my answer answer answer your questions? Is there anything that needs a better explanation?

  • How should I make it so that in relative layout, it stays down and doesn’t go up? I don’t know why it says it’s relativeLayout

  • What are you referring to? Here is no Relativelayout.

  • How to fix this error in a relative layout even if you don’t have it here, the error of the button leaving the place when I push Keyboard

1 answer

2


This view is not constrained, it only has designtime positions, so it will jump to (0,0) unless you add constraints.

That notice indicates that views declare no restrictions(constraints) sufficient to be positioned.

That is, the views do not indicate how they should be positioned in relation to each other or their layout "father". They will be positioned at the coordinates (0.0).

In a Constraintlayout each view shall declare at least one horizontal and one vertical constraint. Each constraint represents a link or alignment to another view, layout "parent" or an orientation.
Each restriction defines the view position along the vertical or horizontal axis.

The editor of layouts Android Studio, to show the layout consistently, automatically adds constraint attributes with absolute values, using the namespace tools.
However they are not used at runtime.

These attributes are:

tools:layout_editor_absoluteX="valor"
tools:layout_editor_absoluteY="valor"

You have to add restrictions so that the views can be positioned without the need for the editor to add these attributes.

For more information on using Constraintlayout see:

Browser other questions tagged

You are not signed in. Login or sign up in order to post.