应用无法在Nexus5模拟器上正确显示

时间:2020-04-09 14:03:27

标签: android-studio android-layout emulation

这是我第一次在这里发帖。

我正在为我的应用程序编写一些代码。它已经运行了好几天了。今天我在实际的电话上尝试过。看起来不错。然后,我打开了仿真器(特别是Nexus 5),但没有完全显示出来。

我尝试了其他虚拟设备,但它们显示正确。我还“冷启动”了Nexus5。看看是否是问题所在。没变化。我卸载并重新安装了Nexus 5,但无济于事。我也重新启动了我的机器。问题仍然存在。

这是XML。

 <?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.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"
    android:background="@drawable/background"
    tools:context=".MainActivity">


    <AutoCompleteTextView
        android:id="@+id/nameTextView"
        android:layout_width="260dp"
        android:layout_height="49dp"
        android:layout_marginTop="68dp"
        android:background="@drawable/username_rectangle"
        android:drawableLeft="@drawable/user_icon"
        android:drawablePadding="15dp"
        android:fontFamily="@font/opine_heavy_font"
        android:hint="@string/username"
        android:paddingStart="30dp"
        android:textColorHint="@color/orange"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.503"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/logo" />

    <EditText
        android:id="@+id/passwordTextView"
        android:layout_width="260dp"
        android:layout_height="49dp"
        android:layout_marginTop="16dp"
        android:background="@drawable/username_rectangle"
        android:drawableLeft="@drawable/pass_icon"
        android:drawablePadding="15dp"
        android:ems="10"
        android:fontFamily="@font/opine_heavy_font"
        android:hint="@string/password"
        android:inputType="textPassword"
        android:paddingStart="30dp"
        android:textColorHint="@color/orange"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/nameTextView" />

    <TextView
        android:id="@+id/forgotPass"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="16dp"
        android:gravity="center_horizontal"
        android:inputType="textPersonName"
        android:text="Forgot Password?"
        android:textColor="@color/grey_white"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/passwordTextView" />

    <TextView
        android:id="@+id/dontHaveAnAccount"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="20dp"
        android:gravity="center_horizontal"
        android:inputType="textPersonName"
        android:text="@string/dont_have_acc"
        android:textColor="@color/grey_white"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.497"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/logInButton" />

    <Button
        android:id="@+id/signUpNow"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:gravity="center_horizontal|center_vertical"
        android:inputType="textPersonName"
        android:background="@color/black"
        android:text="@string/sign_up_now"
        android:textColor="@color/white"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/dontHaveAnAccount" />

    <ImageView
        android:id="@+id/logo"
        android:layout_width="248dp"
        android:layout_height="128dp"
        android:layout_marginTop="156dp"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.496"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:srcCompat="@drawable/logo" />

    <Button
        android:id="@+id/logInButton"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="LOG IN"
        android:textColor="@color/colorPrimary"
        android:background="@drawable/button_background"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/forgotPass" />

</androidx.constraintlayout.widget.ConstraintLayout>

这些是它在Nexus 5x上运行的屏幕截图

Nexus 5x (working Properly)

这就是在Nexus 5上的外观。

Not showing everything on Nexus 5

奇怪的是,我没有更改我刚刚粘贴的Layout XML中的任何内容,前几天在Nexus 5上运行得很好。

唯一的变化是在另一个XML上(在Nexus 5上也无法正确显示):我只是将重力添加到了线性布局中的某些按钮上。今天是我第一次在物理设备上运行我的应用程序。但是我不明白为什么考虑到我已经超过一个月没有更改此部分的单行代码,登录屏幕XML才会受到影响。

0 个答案:

没有答案