Android ImageView is very slow

My problem is that my Scrollview is very slow and slow

Each time I scroll, I receive the following warning:

Skipped 146 frames!  The application may be doing too much work on its main thread.

This is my XML file:

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content">

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <ImageView
        android:id="@+id/c1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:adjustViewBounds="true"
        android:src="@drawable/course1" />

    <TextView
        android:id="@+id/c1text"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/c1"
        android:gravity="center"
        android:text="BlaBla1"
        android:textSize="20sp"
        android:textStyle="bold" />

    <ImageView [...] />

    <TextView [...] />

    [more ImageViews and TextViews]
</RelativeLayout>

What solutions can optimize the loading of images?

resolvent:

The most obvious solution is to use the listview expected by Android

The reason for using listview is that it can reclaim its display to maintain minimum memory consumption. When used with viewholder pattern or even Picasso or glass library, it can easily preload and cache, and provide you with better performance

Unfortunately, the only option is to manually preload images in the background, but this consumes memory and may cause the application to shut down

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>