object problem on top of each other in Android Studio

Asked

Viewed 1,379 times

1

I’m learning to create android apps, but face appears an error when I test the app on mobile, and text is on top of each other, or any object I add.

No meu celular

in Android studio is like this:

inserir a descrição da imagem aqui

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="meuprimeiroapp.studio.com.meuprimeiroapp.MainActivity">

    <TextView
        android:id="@+id/txtLogin"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Login:"
        android:textColor="#000"
        android:textSize="40sp"
        android:textStyle="bold"
        tools:layout_editor_absoluteX="0dp"
        tools:layout_editor_absoluteY="103dp" />

    <TextView
        android:id="@+id/txtPass"
        android:layout_width="127dp"
        android:layout_height="53dp"
        android:text="Senha:"
        android:textColor="#000"
        android:textSize="40sp"
        android:textStyle="bold"
        tools:layout_editor_absoluteX="0dp"
        tools:layout_editor_absoluteY="16dp" />

    <EditText
        android:id="@+id/editText2"
        android:layout_width="460dp"
        android:layout_height="55dp"
        android:ems="10"
        android:inputType="textEmailAddress"
        tools:layout_editor_absoluteX="136dp"
        tools:layout_editor_absoluteY="16dp" />

    <EditText
        android:id="@+id/editText4"
        android:layout_width="460dp"
        android:layout_height="48dp"
        android:ems="10"
        android:inputType="textPassword"
        tools:layout_editor_absoluteX="136dp"
        tools:layout_editor_absoluteY="98dp" />
</android.support.constraint.ConstraintLayout>
  • 1

    This is no mistake. You’re not implementing constraints in views. I suggest you take a look at how to use Constraintlayouts. This is a good place: https://codelabs.developers.google.com/codelabs/constraint-layout/

  • Um, thanks for the help I’ll study more about this.

  • Or change the Constraint to relativelayout

2 answers

1


You’re using Constraintlayout, and it works in a different way...

For you, who is starting now, use Linearlayout as root layout, and then put some other Linearlayout inside this root, to go allocating the content

1

In Android Studio is coming by default the Constraint Layout, change the layout, or adapt to Constraint. To use Constraint Layout you can use a tool that automatically adjusts items.

Ferramenta do Android Studio

Or do it manually, which is better, because you do your will.

Create Connection

Browser other questions tagged

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