我的应用程序在智能手机上运行缓慢
My application is working slowly on smartphones
我是 Android 的初级程序员,当我创建一个应用程序并将其安装在我的真实 phone 或其他 phone 上时,它运行非常缓慢(我不谈论模拟器)。
- 文件大小只有 3 MB
- 这发生在我制作的所有应用程序上
- 我在构建之前清理了缓存和项目
我安装应用程序的设备:HTC630、Samsung galexy S7、Samsung Duos j1。
有什么想法吗?
<?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"
android:background="@drawable/bcc">
<LinearLayout
android:layout_width="0dp"
android:layout_height="495dp"
android:orientation="vertical"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent">
<TextView
android:id="@+id/textView2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/edge"
android:layout_marginTop="@dimen/edge"
android:text="Enter your name:"
android:textColor="#FFFFFF"
android:textSize="@dimen/fsize"
android:textStyle="bold"
tools:layout_editor_absoluteX="0dp"
tools:layout_editor_absoluteY="0dp" />
<EditText
android:id="@+id/editText2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/edge"
android:ems="10"
android:inputType="textPersonName"
android:textColor="#FFFFFF"
android:textSize="@dimen/fsize"
tools:layout_editor_absoluteX="0dp"
tools:layout_editor_absoluteY="0dp" />
<Button
android:id="@+id/button2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/edge"
android:layout_marginRight="@dimen/edge"
android:onClick="nxt"
android:text="Next"
android:textSize="@dimen/fsize"
tools:layout_editor_absoluteX="38dp"
tools:layout_editor_absoluteY="0dp" />
</LinearLayout>
</android.support.constraint.ConstraintLayout>
java代码:
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
public void nxt(View view) {
EditText name =(EditText)findViewById(R.id.editText2);
Intent txtint= new Intent(this,Main2Activity.class);
Bundle b = new Bundle();
b.putString("user",name.getText().toString());
txtint.putExtras(b);
startActivity(txtint);
}
}
我终于解决了问题。我在调整背景大小(以适应屏幕)时出错。
我是 Android 的初级程序员,当我创建一个应用程序并将其安装在我的真实 phone 或其他 phone 上时,它运行非常缓慢(我不谈论模拟器)。 - 文件大小只有 3 MB - 这发生在我制作的所有应用程序上 - 我在构建之前清理了缓存和项目 我安装应用程序的设备:HTC630、Samsung galexy S7、Samsung Duos j1。 有什么想法吗?
<?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"
android:background="@drawable/bcc">
<LinearLayout
android:layout_width="0dp"
android:layout_height="495dp"
android:orientation="vertical"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent">
<TextView
android:id="@+id/textView2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/edge"
android:layout_marginTop="@dimen/edge"
android:text="Enter your name:"
android:textColor="#FFFFFF"
android:textSize="@dimen/fsize"
android:textStyle="bold"
tools:layout_editor_absoluteX="0dp"
tools:layout_editor_absoluteY="0dp" />
<EditText
android:id="@+id/editText2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/edge"
android:ems="10"
android:inputType="textPersonName"
android:textColor="#FFFFFF"
android:textSize="@dimen/fsize"
tools:layout_editor_absoluteX="0dp"
tools:layout_editor_absoluteY="0dp" />
<Button
android:id="@+id/button2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/edge"
android:layout_marginRight="@dimen/edge"
android:onClick="nxt"
android:text="Next"
android:textSize="@dimen/fsize"
tools:layout_editor_absoluteX="38dp"
tools:layout_editor_absoluteY="0dp" />
</LinearLayout>
</android.support.constraint.ConstraintLayout>
java代码:
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
public void nxt(View view) {
EditText name =(EditText)findViewById(R.id.editText2);
Intent txtint= new Intent(this,Main2Activity.class);
Bundle b = new Bundle();
b.putString("user",name.getText().toString());
txtint.putExtras(b);
startActivity(txtint);
}
}
我终于解决了问题。我在调整背景大小(以适应屏幕)时出错。