我正在制作一个带有一堆图像按钮的 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/