So I was making an app and in part of it I wanted to have images with text descriptions. I implemented a scrollview with textviews and imageviews. It works, but loads really slowly. I downsized the images so they are roughly 50-150KB each.. Is there a programatic way I can make images load only when they are you on the screen and otherwise be removed from memory?
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="5dp"
android:textSize="25dp"
android:text="Common Vascular Clamps:"
android:textStyle="bold"
/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="10dp"
android:textSize="25dp"
android:text="Profundas"
/>
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="10dp"
android:adjustViewBounds="true"
android:src="@drawable/vascular_clamps_profundas"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="10dp"
android:textSize="25dp"
android:text="Small Debakeys"
/>
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="10dp"
android:adjustViewBounds="true"
android:src="@drawable/vascular_clamps_small_debakeys"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="10dp"
android:textSize="25dp"
android:text="Large Debakeys"
/>
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="10dp"
android:adjustViewBounds="true"
android:src="@drawable/vascular_clamps_large_debakeys"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="10dp"
android:textSize="25dp"
android:text="Curved Debakeys"
/>
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="10dp"
android:adjustViewBounds="true"
android:src="@drawable/vascular_clamps_curved_debakey"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="10dp"
android:textSize="25dp"
android:text="Satinskies"
/>
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="10dp"
android:adjustViewBounds="true"
android:src="@drawable/vascular_clamps_statinskies"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="10dp"
android:textSize="25dp"
android:text="Angled Forgarties"
/>
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="10dp"
android:adjustViewBounds="true"
android:src="@drawable/vascular_clamps_angled_fogarties"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="10dp"
android:textSize="25dp"
android:text="Straight Forgarties"
/>
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="10dp"
android:adjustViewBounds="true"
android:src="@drawable/vascular_clamps_straight_fogarty"/>
</LinearLayout>
</ScrollView>