简体   繁体   中英

When i launch android emulator its different with android studio. How it solve?

[ When i launch android emulator its different with android studio. How it solve?

在此处输入图像描述

Also i have error:Changes were not applied.Added variable(s) does not support value initialization: Adding static primitive com.maksymb.geteat.R$id.linearLayout

Session 'app': Changes were not applied. Added variable(s) does not support value initialization: Adding static primitive com.maksymb.geteat.R$id.linearLayout

<FrameLayout
    android:id="@+id/f1_header_image"
    android:layout_width="3dp"
    android:layout_height="371dp"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintEnd_toStartOf="parent"
    tools:ignore="MissingConstraints"
    tools:layout_editor_absoluteY="0dp">


</FrameLayout>

<ImageView
    android:id="@+id/imageView"
    android:layout_width="100dp"
    android:layout_height="106dp"
    android:contentDescription="GetEat"
    android:scaleType="fitCenter"
    android:src="@drawable/logo"
    tools:ignore="MissingConstraints"
    tools:layout_editor_absoluteX="155dp"
    tools:layout_editor_absoluteY="99dp" />

<TextView
    android:id="@+id/tv_title"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginTop="88dp"
    android:text="Login"
    android:textColor="@color/black"
    android:textSize="18dp"
    android:textStyle="bold"
    app:layout_constraintTop_toBottomOf="@+id/imageView"
    tools:ignore="MissingConstraints"
    tools:layout_editor_absoluteX="16dp" />

<com.google.android.material.textfield.TextInputLayout
    android:id="@+id/til_login_email"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginStart="16dp"
    android:layout_marginTop="35dp"
    android:layout_marginEnd="15dp"
    android:hint="Email id"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintEnd_toStartOf="parent"
    tools:ignore="MissingConstraints">

</com.google.android.material.textfield.TextInputLayout>

<EditText
    android:id="@+id/et_login_email"
    android:layout_width="389dp"
    android:layout_height="66dp"
    android:inputType="textEmailAddress"
    android:text="abc@gmail.com"
    tools:ignore="MissingConstraints"
    tools:layout_editor_absoluteX="5dp"
    tools:layout_editor_absoluteY="332dp" />

<com.google.android.material.textfield.TextInputLayout
    android:id="@+id/til_login_password"
    android:layout_width="390dp"
    android:layout_height="96dp"
    android:hint="Password"
    tools:ignore="MissingConstraints"
    tools:layout_editor_absoluteX="5dp"
    tools:layout_editor_absoluteY="388dp">

    <EditText
        android:id="@+id/et_login_password"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:inputType="textPassword"
        android:text="123456" />

</com.google.android.material.textfield.TextInputLayout>

<Button
    android:id="@+id/btn_login"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    android:layout_marginTop="12dp"
    android:background="@color/colorAccent1"
    android:gravity="center"
    android:text="Login"
    android:textColor="@android:color/white"
    android:textSize="18sp"
    android:textStyle="bold"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintHorizontal_bias="1.0"
    app:layout_constraintStart_toStartOf="@+id/til_login_password"
    app:layout_constraintTop_toBottomOf="@id/til_login_password"
    app:layout_goneMarginEnd="16dp" />

<LinearLayout
    android:id="@+id/linearLayout"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginTop="5dp"
    android:gravity="center_vertical"
    android:orientation="horizontal"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent">

</LinearLayout>

<TextView
    android:id="@+id/tv_register"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:padding="5dp"
    android:text="Register"
    android:textStyle="bold"
    tools:ignore="MissingConstraints"
    tools:layout_editor_absoluteX="222dp"
    tools:layout_editor_absoluteY="585dp" />

<TextView
    android:id="@+id/tv_dnt"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:padding="5dp"
    android:text="Don't have an account?"
    app:layout_constraintBaseline_toBaselineOf="@+id/tv_register"
    tools:ignore="MissingConstraints"
    tools:layout_editor_absoluteX="70dp" />

</androidx.constraintlayout.widget.ConstraintLayout>

You have not setup your constrains and using fixed positions,

remove tools:ignore="MissingConstraints" and let the errors to show up

then remove all tools:layout_editor_absoluteX tools:layout_editor_absoluteY

tools name space only has an affect on android studio preview

to implement and use constrains follow the docs

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM