0

i'm new in android studio and just installed 3.1.3, when i create new project, there no "hello world!" text in my layout. even though, in tutorial, when we create new project, "hello world" text will appear automatically. then, i try to follow instruction in this link

This view is not constrained

i have tried to use "infer constraints" and it doesnt work, how can i fix this??

erorr picture

AskNilesh
  • 67,701
  • 16
  • 123
  • 163

1 Answers1

0

You Are using Constraint layout as parent Layout so you have to provide top , bottom, left and right to view when using constraint layout , user Relative , Linear or any other layout as parent layout or provide constraint layout constraints for view like this example where view is constrained in center of parent with the help of constraints

        <Button
        android:id="@+id/button2"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:text="Button"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"/>
Muhammad Hassaan
  • 874
  • 6
  • 18
  • i've tried your solution, but the button doesn't appear. and there warning occur, "Hardcoded string "Button", should use @string resource". – Fikih Muhamad Jul 29 '18 at 14:44
  • i get the solution for my error, that's not because .xml but because implementation 'com.amdroid. bla bla bla' in my app file. i'm so sorry for bothering you, but thank you – Fikih Muhamad Jul 29 '18 at 15:30