I'm an Android beginner and I'm building a SoundBoard app for fun with a ScrollView
and a lot (44 for now) ImageButton
side by side in 2 columns.
Here is what it looks like :
<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>
When scrolling down fast I experience lags. I tried building the app with a RecyclerView
but it didn't fixed the problem (I may have misused it).
Each .jpg weigh between 20Ko and 30Ko for a total of 1.24Mo for 44 images.
Do you have any clue on how to fix this ?
Thanks !