Why Android Studio Show Error Of "missing Constraints In Constraintlayout"?
Solution 1:
It is very simple to solve this problem. Just click on the widget (for example button or textbox, etc.) then click on the "Infer constraints" Button. You can see in the attached picture or this Youtube link: https://www.youtube.com/watch?v=uOur51u5Nk0
Solution 2:
You might have widgets with attributes:
tools:layout_editor_absoluteX="someValue"
tools:layout_editor_absoluteY="someValue"
tools
namespace is used at development time only, and will be removed while installing apk, so all you layouts might appear at position TOP-LEFT one above other. View Tools Attributes Reference
To fix this: You should make use of Layout Constraints like:
layout_constraintLeft_toLeftOf
layout_constraintLeft_toRightOf
layout_constraintRight_toLeftOf
layout_constraintRight_toRightOf
layout_constraintTop_toTopOf
layout_constraintTop_toBottomOf
layout_constraintBottom_toTopOf
layout_constraintBottom_toBottomOf
layout_constraintBaseline_toBaselineOf
layout_constraintStart_toEndOf
layout_constraintStart_toStartOf
layout_constraintEnd_toStartOf
layout_constraintEnd_toEndOf
You can go through the doc of ConstraintLayout and Build a Responsive UI with ConstraintLayout for more details
EDIT:
From the picture you posted, I tried to add appropriate constraints such that the TextView is in Center position using following code:
<android.support.constraint.ConstraintLayoutxmlns: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"><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:text="TextView"app:layout_constraintBottom_toBottomOf="parent"app:layout_constraintEnd_toEndOf="parent"app:layout_constraintStart_toStartOf="parent"app:layout_constraintTop_toTopOf="parent" /></android.support.constraint.ConstraintLayout>
Solution 3:
"Missing constraints in ConstraintsLayout".This error occurs due to the undefined Constraints.To fix this error click on the Widget(ex text,button etc) and then click on the infer constraints which is above the the activity screen.Hope this solves your query
Post a Comment for "Why Android Studio Show Error Of "missing Constraints In Constraintlayout"?"