android - 我的应用程序在我的设备上无法正常运行

标签 android performance gradle material-design android-cardview

我的Android应用程序ui运行不平稳。当我在手机中运行(Android 5.1)应用程序时,该应用程序正常运行,但运行速度却不如其他应用程序。

当我尝试在 android 7.0中运行应用程序时,效果更好

我需要我想要在任何android设备上更流畅地运行我的应用的帮助。

minSdkVersion应该为19

这是我的build.gradle文件

android {
compileSdkVersion 26
buildToolsVersion "26.0.1"
defaultConfig {
    applicationId "com.blackhat.rhythmbox"
    minSdkVersion 19
    targetSdkVersion 22
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
  }dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
    exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:26.0.1'
compile 'com.android.support:recyclerview-v7:26.0.1'
compile 'com.android.support:cardview-v7:26.0.1'
compile 'com.android.support:design:22.2.0'
testCompile 'junit:junit:4.12'}

这是无法顺利运行的代码
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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:orientation="vertical"
tools:context="com.blackhat.rhythmbox.MainActivity">

<android.support.v7.widget.Toolbar
    android:layout_width="match_parent"
    android:layout_height="55dp"
    android:id="@+id/Maintool"
    android:elevation="4dp"
    android:theme="@style/CustomActionBarTheme">

</android.support.v7.widget.Toolbar>

<HorizontalScrollView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:scrollbars="none">
<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginEnd="8dp"
    android:padding="15dp"
    android:orientation="horizontal"
    tools:layout_editor_absoluteX="8dp"
    tools:layout_editor_absoluteY="0dp">

    <android.support.v7.widget.CardView
        android:layout_width="250dp"
        android:layout_height="150dp"
        android:layout_gravity="center"
        android:background="@drawable/one"
        app:cardCornerRadius="7dp"
        app:cardElevation="12dp">
        <ImageView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="@drawable/simple_two"/>
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="My Favorites"
            android:textSize="25sp"
            android:textColor="#FFFF"
            android:padding="15sp"/>

        <TextView
            android:id="@+id/textView"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="50dp"
            android:layout_marginLeft="15dp"
            android:text="Total  __ Songs"
            android:textColor="#FFFF"
            android:textSize="18sp" />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="bottom"
            android:paddingBottom="10dp"
            android:layout_marginLeft="15dp"
            android:text="Play All Songs"
            android:textColor="#FFFF"
            android:textSize="18sp" />

        <android.support.design.widget.FloatingActionButton
            android:id="@+id/floating_action_button"
            android:layout_width="58dp"
            android:layout_height="58dp"
            android:layout_gravity="bottom|right"
            android:layout_margin="16dp"
            android:src="@drawable/play"
            app:backgroundTint="@android:color/transparent"
            app:borderWidth="0dp" />
    </android.support.v7.widget.CardView>

    <android.support.v7.widget.CardView
        android:layout_width="250dp"
        android:layout_marginLeft="25dp"
        android:layout_height="150dp"
        android:layout_gravity="center"
        app:cardCornerRadius="7dp"
        app:cardElevation="12dp"
        android:background="@drawable/simple_two">
        <ImageView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="@drawable/one"/>
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="My Collection"
            android:textSize="25sp"
            android:textColor="#FFFF"
            android:padding="15sp"/>

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="50dp"
            android:layout_marginLeft="15dp"
            android:text="Total  __ Songs"
            android:textColor="#FFFF"
            android:textSize="18sp" />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="bottom"
            android:paddingBottom="10dp"
            android:layout_marginLeft="15dp"
            android:text="Play All Songs"
            android:textColor="#FFFF"
            android:textSize="18sp" />

        <android.support.design.widget.FloatingActionButton
            android:layout_width="58dp"
            android:layout_height="58dp"
            android:layout_gravity="bottom|right"
            android:layout_margin="16dp"
            android:src="@drawable/play"
            app:backgroundTint="@android:color/transparent"
            app:borderWidth="0dp" />

    </android.support.v7.widget.CardView>

</LinearLayout>
</HorizontalScrollView>
<android.support.design.widget.TabLayout
    android:id="@+id/tabs"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    app:tabGravity="fill"
    app:tabMode="fixed"
    />
<FrameLayout
    android:id="@+id/frame_container"
    android:layout_width="match_parent"
    android:layout_height="match_parent" />

</LinearLayout>

请帮忙。

这是我的最后一个项目,stackoverflow是最后的希望

最佳答案

我通过将以下行添加到AndroidManifest.xml文件

android:hardwareAccelerated="false"
android:largeHeap="true"
中解决了此问题

关于android - 我的应用程序在我的设备上无法正常运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48239212/

相关文章:

android - 如何通过 URI 打开 native 名片

performance - 上下文切换的价格是多少?与依靠OS线程相比,实现手动任务切换是否更好?

spring-boot - 尝试使用Gradle运行克隆的项目但无法构建

java - 为什么今天开发Android需要与gradle同步?

docker - 如何解决 Raspberry Pi 上的 Gradle docker 图像卡住问题并发出有关单调时钟的警告?

java - 如何将数据从 fragment 发送到 fragment ?

java - 如何在屏幕上只显示 map 的一部分

algorithm - K个最近的点。时间复杂度 O(n),而不是 O(nLogn)。如何?

javascript - 针对常量求值的 Angular 表达式

android - 按日期对 ListView 进行排序?