我正在使用Login制作应用。应用程序上的其他所有内容都可以使用任何设备以正常速度运行,但在使用EditText和显示android键盘时,我的登录活动在某些设备上运行速度非常慢。在我的手机上是三星Young 2(真的便宜又慢的手机),它真的很快,但在我的一个朋友的Huaweii Y6上它运行得非常慢(便宜的手机,但不是那么慢),以及在Huaweii P8上它运行缓慢。这是XML代码(java代码没有干涉,因为我删除了试图查看是否是这种情况):
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout 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:fitsSystemWindows="true"
tools:context="com.example.uta2.rallyuninorte.Login">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fitsSystemWindows="true"
android:orientation="vertical"
android:focusable="true"
android:focusableInTouchMode="true"
android:background="@color/white"
android:layout_marginTop="60dp"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:weightSum="1">
<ImageView android:src="@drawable/logo_rali"
android:layout_width="wrap_content"
android:layout_height="120dp"
android:layout_marginBottom="10dp"
android:layout_gravity="center_horizontal"
android:scaleType="centerCrop" />
<!-- User Label -->
<TextView
android:id="@+id/response"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp">
<EditText android:id="@+id/user_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="text"
android:hint="Usuario" />
</android.support.design.widget.TextInputLayout>
<!-- Activity Label -->
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp">
<EditText android:id="@+id/activity_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="text"
android:hint="Actividad"/>
</android.support.design.widget.TextInputLayout>
<Button
android:id="@+id/btn_login"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="40dp"
android:padding="12dp"
android:text="Entrar"
android:layout_marginLeft="40dp"
android:layout_marginRight="40dp"
android:onClick="open_menu"
android:textColor="@color/white"
android:background="@color/colorPrimary"/>
</LinearLayout>
</android.support.design.widget.CoordinatorLayout>
解决方案:
正如他们所写,问题是logo_rali图像,尺寸仅为46kb,但图像尺寸为1600x1200。我改为280x190并解决了我的问题