0

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>
Pat
  • 43
  • 3
  • 1
    It may be help you http://stackoverflow.com/a/35222639/1443888 – Gurjit Singh Sep 25 '16 at 16:21
  • You have to lazy load the images. checkout http://stackoverflow.com/questions/541966/lazy-load-of-images-in-listview . I personally prefer [this](http://stackoverflow.com/a/8562313/1630255) answer. – Neeraj Sep 25 '16 at 16:58

0 Answers0