0

I have just now started learning android programming. simple app which has got a scollview functionality. The text part scrolls fine but when image is about to come in the view on scrolling, the scrolling stucks and gets slow as if the app is hanging but somehow the scrolling completes in the end with the image.

May I know the reason for this and how to rectify this issue?

Below is the XML code for my app:

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.nitishsinha.parsefeed.ParseFeed">

<LinearLayout
android:id="@+id/activity_parse_feed"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
>

<TextView
    android:id="@+id/Title"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/imageTitle" />
<TextView
    android:id="@+id/Date"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/imageDate" />
<ImageView
    android:id="@+id/Image"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:src="@drawable/ganpati" />
<TextView
    android:id="@+id/Description"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/imageDesc" />
</LinearLayout>
</ScrollView>

2 Answers2

0

You might want to look at the image size. If you are pushing a large image then things will slow down. adjust your image size according to the size of the ImageView. That was my problem on a site I was building. I had to create two copies for each image. One to display quick and one for detail. Not sure if this will help you. Good luck

  • Thanks for the suggestion! Yes. I understand the issue is due to large size of the image and it works on reducing the size of the image. But the thing is that I am in the process of building an app for parse feed so I cannot reduce the size of image manually. I will need to use code. I have used the code available on this site however the problem is still not resolved: https://developer.android.com/topic/performance/graphics/load-bitmap.html – Code Funda Mar 30 '17 at 18:04
0

You can use Glide or Piccaso for image loading. they have implemented it very well even google devs suggest to use it. For ref check this - Lazy load of images in ListView

Or

https://inthecheesefactory.com/blog/get-to-know-glide-recommended-by-google/en

Community
  • 1
  • 1
Wasim K. Memon
  • 5,979
  • 4
  • 40
  • 55