Android Studio: everything appears out of square [duplicated]

1

I have a small code in Android Studio with a couple of buttons, an EditText and a TextView, all quite basic. In the preview everything comes to me more or less as I want, well squared and so on, as you can see in the following image, the part on the left:

The problem is that when I try to test the operation of the app from the Android Studio virtual machine everything appears moved from site, specifically top left (is the image on the top right).

Does anyone know exactly what the problem is? I'm very new with Android Studio so I guess it must be any trifle. I leave the xml code below for help:

A part of the code does not appear I do not know why, I put it as an image (it's the initial code, before TextView). Below the whole code does not appear but the constraintlayout is closed correctly:

<TextView
    android:id="@+id/NomCognoms"
    android:layout_width="112dp"
    android:layout_height="31dp"
    android:text="Nom i cognoms"
    android:visibility="visible"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintHorizontal_bias="0.058"
    app:layout_constraintLeft_toLeftOf="parent"
    app:layout_constraintRight_toRightOf="parent"
    app:layout_constraintTop_toTopOf="parent"
    app:layout_constraintVertical_bias="0.033" />

<EditText
    android:id="@+id/edittext_nomcognoms"
    android:layout_width="179dp"
    android:layout_height="42dp"
    android:layout_centerHorizontal="true"
    android:layout_centerVertical="true"
    tools:layout_editor_absoluteX="16dp"
    tools:layout_editor_absoluteY="47dp" />

<ImageButton
    android:id="@+id/botoAcceptar"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    app:srcCompat="@android:drawable/ic_input_add"
    tools:layout_editor_absoluteX="236dp"
    tools:layout_editor_absoluteY="16dp" />

<ImageButton
    android:id="@+id/botoCancelar"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    app:srcCompat="@android:drawable/ic_delete"
    tools:layout_editor_absoluteX="299dp"
    tools:layout_editor_absoluteY="16dp" />

Greetings and thanks

    
asked by MarcusF 20.09.2017 в 15:13
source

1 answer

1

The problem is that you use tools:... that is for design view, that's why it shows you all "well" but the controls are not chained and that's why they come out together.

if you notice the first element if you establish chaining:

app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintHorizontal_bias="0.058"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"

but the others nothing ...

To solve eliminate all the tools: and go to the blue screen where you can see the pivots arriba, derecha, abajo, izquierda and make the chains to adjust them to the appropriate position.

    
answered by 20.09.2017 / 15:25
source