android - android中的图像按钮加载时间慢

标签 android performance scrollview imagebutton

我正在制作一个带有一堆图像按钮的 ScrollView 。不幸的是,这个 View 需要很长时间才能加载 - 如此之多以至于用户可能会认为这是一个错误而关闭应用程序。

关于如何加快此过程的任何想法?

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >

<TableLayout
    android:layout_height="fill_parent"
    android:layout_width="fill_parent"
    >
    <TableRow> 
        <ImageButton
            android:id="@+id/ImageButtonCone"
            android:layout_width="160dp"
            android:layout_height="200dp"
            android:scaleType="fitCenter"
            android:background="@drawable/cone" 
            />
        <ImageButton
            android:id="@+id/ImageButtonCube"
            android:layout_width="160dp"
            android:layout_height="200dp"
            android:scaleType="fitCenter"
            android:background="@drawable/cube" 
            />
    </TableRow>
            <TableRow> 
        <ImageButton
            android:id="@+id/ImageButtonCylinder"
            android:layout_width="160dp"
            android:layout_height="200dp"
            android:scaleType="fitCenter"
            android:background="@drawable/cylinder" 
            />
        <ImageButton
            android:id="@+id/ImageButtonTrapezoidalprism"
            android:layout_width="160dp"
            android:layout_height="200dp"
            android:scaleType="fitCenter"
            android:background="@drawable/trapezoidal_prism" 
            />

等...

最佳答案

我已经解决了问题...我在 drawable-mdpi 文件夹中只有 png 而不是其他 drawable 文件夹。我已经复制了每个 png 并将它们粘贴到 drawable-ldpi、drawable-mdpi 和 drawable-xhdpi 中,现在它在手机和模拟器上运行得非常快。

据推测,模拟器采用的是中等清晰度 .png,但手机想要采用不同的分辨率,但无法做到。

关于android - android中的图像按钮加载时间慢,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12541225/

相关文章:

android - Uri.withAppendedPath 方法

python - Django ManyToMany 模板渲染和性能问题

ruby-on-rails - 如何不需要 "rails/all"?

android - Gallery 内的 ScrollView,两者独立滚动

java - "ScrollView can only host 1 child"在 2 个 fragment 中,只有 1 个 child ?

java - Android ScrollView 不以相对布局滚动

android - libgdx 还是 playn?

android - 从 Android 应用程序中打开特定文件

android - LinearLayout$LayoutParams 无法转换为 android.widget.FrameLayout$LayoutParams

c - 编写此代码片段的有效方法?