【发布时间】:2017-03-23 02:22:14
【问题描述】:
我是一名 Android 初学者,我正在构建一个有趣的 SoundBoard 应用程序,与 ScrollView 和很多(目前为 44 个)ImageButton 并排在 2 列中。
这是它的样子:
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="1dp"
android:orientation="horizontal"
android:weightSum="1">
<ImageButton
android:id="@+id/myImageButton1"
android:tag="myTag1"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginRight="1dp"
android:layout_weight=".5"
android:adjustViewBounds="true"
android:background="@null"
android:clickable="true"
android:foreground="?attr/selectableItemBackgroundBorderless"
android:onClick="onSoundButtonClick"
android:scaleType="fitXY"
android:src="@drawable/myImage1" />
<ImageButton
android:id="@+id/myImageButton2"
android:tag="myTag2"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight=".5"
android:adjustViewBounds="true"
android:background="@null"
android:clickable="true"
android:foreground="?attr/selectableItemBackgroundBorderless"
android:onClick="onSoundButtonClick"
android:scaleType="fitXY"
android:src="@drawable/myImage2" />
</LinearLayout>
// More LinearLayout below for ImageButton side by side
</LinearLayout>
快速向下滚动时,我会遇到延迟。我尝试使用RecyclerView 构建应用程序,但它并没有解决问题(我可能误用了它)。
每个 .jpg 的重量在 20Ko 到 30Ko 之间,总共 1.24Mo,共 44 张图像。
你知道如何解决这个问题吗?
谢谢!
【问题讨论】:
-
使用 Picasso 它是一个 Imageloader Lib,它会在需要时加载图像,以及它在后台线程上的工作,请查看此链接:simplifiedcoding.net/…
-
@ItzikSamara 我试过毕加索,它就像一个魅力!但是我找不到在一个项目上播放声音的方法......互联网上没有任何相关内容,你知道如何做吗?
标签: android scrollview imagebutton lag