我是android开发者。 大多数情况下,我使用ConstraintLayout来提高性能。 但是,我的应用程序比原始项目慢。 main_activity.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"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toTopOf="@id/guideline0"
android:layout_height="0dp"
app:layout_constraintHeight_percent="0.5">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/intro_logo"
android:id="@+id/introLogo"/>
</android.support.constraint.ConstraintLayout>
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:background="#23314d"
app:layout_constraintHeight_percent="0.5"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/guideline0">
<android.support.constraint.Guideline
android:id="@+id/guideline1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintGuide_percent="0.05" />
<android.support.constraint.Guideline
android:id="@+id/guideline2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintGuide_percent="0.2" />
<android.support.constraint.Guideline
android:id="@+id/guideline3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintGuide_percent="0.35" />
<android.support.constraint.Guideline
android:id="@+id/guideline4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintGuide_percent="0.5" />
<android.support.constraint.Guideline
android:id="@+id/guideline5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintGuide_percent="0.65" />
<android.support.constraint.Guideline
android:id="@+id/guideline6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintGuide_percent="0.8" />
<android.support.constraint.Guideline
android:id="@+id/guideline7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintGuide_percent="0.95" />
<View
android:layout_width="1dp"
android:layout_height="0dp"
android:background="#ffffff"
app:layout_constraintBottom_toTopOf="@+id/kisanLogo"
app:layout_constraintHeight_percent="0.2"
app:layout_constraintLeft_toLeftOf="@id/guideline1"
app:layout_constraintRight_toRightOf="@id/guideline1"
app:layout_constraintTop_toTopOf="parent" />
<View
android:layout_width="1dp"
android:layout_height="0dp"
android:background="#ffffff"
app:layout_constraintBottom_toTopOf="@+id/kisanLogo"
app:layout_constraintHeight_percent="0.2"
app:layout_constraintLeft_toLeftOf="@id/guideline2"
app:layout_constraintRight_toRightOf="@id/guideline2"
app:layout_constraintTop_toTopOf="parent" />
<View
android:layout_width="1dp"
android:layout_height="0dp"
android:background="#ffffff"
app:layout_constraintBottom_toTopOf="@+id/kisanLogo"
app:layout_constraintHeight_percent="0.2"
app:layout_constraintLeft_toLeftOf="@id/guideline3"
app:layout_constraintRight_toRightOf="@id/guideline3"
app:layout_constraintTop_toTopOf="parent" />
<View
android:id="@+id/view4"
android:layout_width="1dp"
android:layout_height="0dp"
android:background="#ffffff"
app:layout_constraintBottom_toTopOf="@+id/kisanLogo"
app:layout_constraintHeight_percent="0.2"
app:layout_constraintLeft_toLeftOf="@id/guideline4"
app:layout_constraintRight_toRightOf="@id/guideline4"
app:layout_constraintTop_toTopOf="parent" />
<View
android:layout_width="1dp"
android:layout_height="0dp"
android:background="#ffffff"
app:layout_constraintBottom_toTopOf="@+id/kisanLogo"
app:layout_constraintHeight_percent="0.2"
app:layout_constraintLeft_toLeftOf="@id/guideline5"
app:layout_constraintRight_toRightOf="@id/guideline5"
app:layout_constraintTop_toTopOf="parent" />
<View
android:layout_width="1dp"
android:layout_height="0dp"
android:background="#ffffff"
app:layout_constraintBottom_toTopOf="@+id/kisanLogo"
app:layout_constraintHeight_percent="0.2"
app:layout_constraintLeft_toLeftOf="@id/guideline6"
app:layout_constraintRight_toRightOf="@id/guideline6"
app:layout_constraintTop_toTopOf="parent" />
<View
android:layout_width="1dp"
android:layout_height="0dp"
android:background="#ffffff"
app:layout_constraintBottom_toTopOf="@+id/kisanLogo"
app:layout_constraintHeight_percent="0.2"
app:layout_constraintLeft_toLeftOf="@id/guideline7"
app:layout_constraintRight_toRightOf="@id/guideline7"
app:layout_constraintTop_toTopOf="parent" />
<Button
android:id="@+id/realCountInformation"
android:layout_width="0dp"
android:layout_height="0dp"
android:background="@drawable/btn_main_count_information"
app:layout_constraintBottom_toTopOf="@id/realCountInformationTv"
app:layout_constraintLeft_toLeftOf="@id/guideline1"
app:layout_constraintRight_toRightOf="@id/guideline2"
app:layout_constraintTop_toTopOf="@id/guideHori1" />
<Button
android:id="@+id/showingCoutLog"
android:layout_width="0dp"
android:layout_height="0dp"
android:background="@drawable/btn_main_showing_count_log"
app:layout_constraintBottom_toTopOf="@id/showingCoutLogTv"
app:layout_constraintLeft_toLeftOf="@id/guideline2"
app:layout_constraintRight_toRightOf="@id/guideline3"
app:layout_constraintTop_toTopOf="@id/guideHori1" />
<Button
android:id="@+id/showingAdvertisement"
android:layout_width="0dp"
android:layout_height="0dp"
android:background="@drawable/btn_main_showing_advertisement"
app:layout_constraintBottom_toTopOf="@id/showingAdvertisementTv"
app:layout_constraintLeft_toLeftOf="@id/guideline3"
app:layout_constraintRight_toRightOf="@id/guideline4"
app:layout_constraintTop_toTopOf="@id/guideHori1" />
<Button
android:id="@+id/configureAdvertisement"
android:layout_width="0dp"
android:layout_height="0dp"
android:background="@drawable/btn_main_configure_advertisement"
app:layout_constraintBottom_toTopOf="@id/configureAdvertisementTv"
app:layout_constraintLeft_toLeftOf="@id/guideline4"
app:layout_constraintRight_toRightOf="@id/guideline5"
app:layout_constraintTop_toTopOf="@id/guideHori1" />
<Button
android:id="@+id/userManagement"
android:layout_width="0dp"
android:layout_height="0dp"
android:background="@drawable/btn_main_user_management"
app:layout_constraintBottom_toTopOf="@id/userManagementTv"
app:layout_constraintLeft_toLeftOf="@id/guideline5"
app:layout_constraintRight_toRightOf="@id/guideline6"
app:layout_constraintTop_toTopOf="@id/guideHori1" />
<Button
android:id="@+id/configure"
android:layout_width="0dp"
android:layout_height="0dp"
android:background="@drawable/btn_main_configure"
app:layout_constraintBottom_toTopOf="@id/configureTv"
app:layout_constraintLeft_toLeftOf="@id/guideline6"
app:layout_constraintRight_toRightOf="@id/guideline7"
app:layout_constraintTop_toTopOf="@id/guideHori1" />
<TextView
android:id="@+id/realCountInformationTv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/real_time_counting"
android:textColor="#FFFFFF"
android:textSize="@dimen/default_intro_text_size"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="@id/guideHori2"
app:layout_constraintLeft_toLeftOf="@id/guideline1"
app:layout_constraintRight_toRightOf="@id/guideline2"
app:layout_constraintTop_toBottomOf="@id/realCountInformation" />
<TextView
android:id="@+id/showingCoutLogTv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/count_history"
android:textColor="#FFFFFF"
android:textSize="@dimen/default_intro_text_size"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="@id/guideHori2"
app:layout_constraintLeft_toLeftOf="@id/guideline2"
app:layout_constraintRight_toRightOf="@id/guideline3"
app:layout_constraintTop_toBottomOf="@id/showingCoutLog" />
<TextView
android:id="@+id/showingAdvertisementTv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/view_ad"
android:textColor="#FFFFFF"
android:textSize="@dimen/default_intro_text_size"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="@id/guideHori2"
app:layout_constraintLeft_toLeftOf="@id/guideline3"
app:layout_constraintRight_toRightOf="@id/guideline4"
app:layout_constraintTop_toBottomOf="@id/showingAdvertisement" />
<TextView
android:id="@+id/configureAdvertisementTv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/ad_setting"
android:textColor="#FFFFFF"
android:textSize="@dimen/default_intro_text_size"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="@id/guideHori2"
app:layout_constraintLeft_toLeftOf="@id/guideline4"
app:layout_constraintRight_toRightOf="@id/guideline5"
app:layout_constraintTop_toBottomOf="@id/configureAdvertisement" />
<TextView
android:id="@+id/userManagementTv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/user_management"
android:textColor="#FFFFFF"
android:textSize="@dimen/default_intro_text_size"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="@id/guideHori2"
app:layout_constraintLeft_toLeftOf="@id/guideline5"
app:layout_constraintRight_toRightOf="@id/guideline6"
app:layout_constraintTop_toBottomOf="@id/userManagement" />
<TextView
android:id="@+id/configureTv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/setting"
android:textColor="#FFFFFF"
android:textSize="@dimen/default_intro_text_size"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="@id/guideHori2"
app:layout_constraintLeft_toLeftOf="@id/guideline6"
app:layout_constraintRight_toRightOf="@id/guideline7"
app:layout_constraintTop_toBottomOf="@id/configure" />
<ImageView
android:id="@+id/kisanLogo"
android:layout_width="0dp"
android:layout_height="0dp"
android:src="@drawable/kisan_logo"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintHeight_percent="0.2"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/guideHori2"
app:layout_constraintWidth_percent="0.2" />
<android.support.constraint.Guideline
android:id="@+id/guideHori1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintGuide_percent="0.15" />
<android.support.constraint.Guideline
android:id="@+id/guideHori2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintGuide_percent="0.55" />
</android.support.constraint.ConstraintLayout>
<android.support.constraint.Guideline
android:layout_width="wrap_content"
android:id="@+id/guideline0"
android:layout_height="wrap_content"
app:layout_constraintGuide_percent="0.5"
android:orientation="horizontal"/>
</android.support.constraint.ConstraintLayout>
此代码在我的平板电脑(便宜)中非常慢。 如何提高我的应用程序性能,为什么这么慢? 这个应用程序的加载时间在我的平板电脑中是2~5秒。 这很严重。我想提高布局的性能。 如何更改上面代码的代码。