Saleh Mosleh Saleh Mosleh - 3 months ago 7
Java Question

how to fix Delays in scrolling on my android app

in my main page app , When scrolling, delayed !
how to fix it ?!

I've compressed images by Photoshop and The total size of all images is <= 100kb and type of images are jpg and png ...

here is my main_layout.xml codes :

<?xml version="1.0" encoding="utf-8"?><FrameLayout
android:layo`enter code here`ut_width="match_parent"
android:layout_height="match_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto">
<android.support.v4.widget.DrawerLayout
android:id="@+id/drawer_layout_main" android:layoutDirection="rtl"
android:layout_width="fill_parent"
android:layout_height="fill_parent">

<AbsoluteLayout
android:layout_width="match_parent" android:id="@+id/content_frame"
android:layout_height="match_parent" android:background="#EEEEEE"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin">


<ScrollView
android:layout_width="fill_parent"
android:layout_height="match_parent" android:fillViewport="true"
android:id="@+id/mainscrollView" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@null" android:layoutDirection="ltr"
android:orientation="vertical">

<include layout="@layout/find_my_around" />


<include layout="@layout/maxoption_first_page" />



<FrameLayout
android:layout_width="fill_parent"
android:layout_height="50dp"
android:background="@null" >

<TextView
android:layout_width="wrap_content"
android:layout_height="fill_parent" android:layout_gravity="right"
android:layout_marginRight="5dp" android:tag="persian"
android:text="برترین ها در شهر"
android:gravity="right|center_vertical"
android:textColor="#000000"
android:textSize="19sp" />

<com.balysv.materialripple.MaterialRippleLayout
android:layout_width="wrap_content" android:layout_height="wrap_content"
app:mrl_rippleOverlay="true"
app:mrl_rippleColor="#ff7584"
app:mrl_rippleAlpha="0.3"
app:mrl_rippleDelayClick="false"
app:mrl_rippleHover="true"
app:mrl_rippleDuration="400"
app:mrl_rippleFadeDuration="250" android:layout_marginLeft="5dp"
android:layout_marginTop="10dp" android:layout_gravity="left"
android:layout_marginBottom="10dp" >
<Button
android:layout_width="70dp" android:gravity="center|center_vertical"
android:layout_height="30dp" android:tag="persian"
android:text="بیشتر >"
android:id="@+id/morebzpbest"
android:textColor="#000000"
android:background="#ffc518" />
</com.balysv.materialripple.MaterialRippleLayout>
</FrameLayout>


<org.lucasr.twowayview.TwoWayView
android:id="@+id/bestcity"
style="@style/TwoWayView" android:layoutDirection="rtl"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:drawSelectorOnTop="false"
tools:context=".BazardanApp" />


<include layout="@layout/iamhungrybanner"/>

<LinearLayout
android:layout_width="fill_parent" android:orientation="vertical" android:id="@+id/foodstation"
android:layout_height="wrap_content">
<FrameLayout
android:layout_width="fill_parent"
android:layout_height="50dp"
android:background="@null" >

<TextView
android:layout_width="wrap_content"
android:layout_height="fill_parent" android:layout_gravity="right"
android:layout_marginRight="5dp" android:tag="persian"
android:text="ایستگاه غذا"
android:gravity="right|center_vertical"
android:textColor="#000000"
android:textSize="19sp" />

<com.balysv.materialripple.MaterialRippleLayout
android:layout_width="wrap_content" android:layout_height="wrap_content"
app:mrl_rippleOverlay="true"
app:mrl_rippleColor="#ff7584" android:id="@+id/ripplemenuop765"
app:mrl_rippleAlpha="0.3"
app:mrl_rippleDelayClick="false"
app:mrl_rippleHover="true"
app:mrl_rippleDuration="400"
app:mrl_rippleFadeDuration="250" android:layout_marginLeft="5dp"
android:layout_marginTop="10dp" android:layout_gravity="left"
android:layout_marginBottom="10dp" >
<Button
android:layout_width="70dp" android:gravity="center|center_vertical"
android:layout_height="30dp" android:tag="persian"
android:text="بیشتر >"
android:id="@+id/morestationfoods"
android:textColor="#000000"
android:background="#ffc518" />
</com.balysv.materialripple.MaterialRippleLayout>
</FrameLayout>

<org.lucasr.twowayview.TwoWayView
android:id="@+id/bestmenubzps"
style="@style/TwoWayView" android:layoutDirection="rtl"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:drawSelectorOnTop="false"
tools:context=".BazardanApp" />

</LinearLayout>







</LinearLayout>
</ScrollView>

<include layout="@layout/full_screen_loader_by_wifichecker"/>

<include layout="@layout/custom_actionbar"/>


</AbsoluteLayout>

<include layout="@layout/main_menu"/>

</android.support.v4.widget.DrawerLayout>

<include layout="@layout/gettextlayout"/>
<include layout="@layout/signup_notfi"/>
<include layout="@layout/requestfor_signup"/>
<include layout="@layout/requestfor_salecredit"/>
<include layout="@layout/bazardan_id_finder"/>
<include layout="@layout/you_have_gift"/>




here is find_my_around.xml codes :

<?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="fill_parent"
android:id="@+id/findmyaround"
android:layout_height="270dp"
android:gravity="center|center_vertical">
<com.balysv.materialripple.MaterialRippleLayout
android:layout_width="wrap_content" android:layout_height="wrap_content"
app:mrl_rippleOverlay="true"
app:mrl_rippleColor="#ffffff"
app:mrl_rippleAlpha="0.3"
app:mrl_rippleDelayClick="false"
app:mrl_rippleHover="true"
app:mrl_rippleDuration="400"
app:mrl_rippleFadeDuration="250" >
<FrameLayout
android:layout_width="fill_parent" android:layout_centerInParent="true"
android:layout_centerVertical="true" android:layout_centerHorizontal="true"
android:layout_height="fill_parent" android:id="@+id/serachmayaround">
<ImageView
android:layout_width="fill_parent" android:src="@drawable/bgmyaround" android:id="@+id/bgmyaroundimg"
android:layout_height="fill_parent" android:scaleType="centerCrop" />

<ImageView
android:layout_width="fill_parent" android:src="@drawable/bgmyerondshadow" android:layout_gravity="bottom"
android:layout_height="100dp" android:scaleType="fitXY" />

<LinearLayout
android:layout_width="fill_parent" android:orientation="vertical" android:layout_gravity="center|center_vertical"
android:layout_height="fill_parent" android:gravity="center|center_vertical" android:layout_marginTop="10dp">

<ImageButton
android:layout_width="60dp"
android:background="@drawable/roundedbutton60"
android:src="@drawable/mycurentlocation"
android:scaleType="centerInside" android:layout_gravity="center|center_vertical"
android:padding="10dp"
android:layout_height="60dp" />

<TextView
android:layout_width="fill_parent" android:textSize="20sp" android:textColor="#fff"
android:layout_marginTop="10dp" android:text="اطراف خود را کشف کنید !"
android:layout_height="wrap_content" android:layout_marginLeft="10dp" android:layout_marginRight="10dp"
android:gravity="center|center_vertical" android:layout_gravity="center|center_vertical"
android:id="@+id/textpersia344" />

</LinearLayout>
</FrameLayout>
</com.balysv.materialripple.MaterialRippleLayout>




here is maxoption_first_page.xml codes :

<?xml version="1.0" encoding="utf-8"?><LinearLayout
android:layout_width="fill_parent"
android:orientation="vertical"
android:layout_height="wrap_content"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">

<LinearLayout
android:layout_width="fill_parent"
android:orientation="horizontal"
android:layout_height="150dp"
android:gravity="left"
android:baselineAligned="false" >
<com.balysv.materialripple.MaterialRippleLayout
app:mrl_rippleOverlay="true"
app:mrl_rippleColor="#ffa911"
app:mrl_rippleAlpha="0.3"
app:mrl_rippleDelayClick="false"
app:mrl_rippleHover="true"
app:mrl_rippleDuration="400" android:layout_gravity="left"
app:mrl_rippleFadeDuration="250" android:layout_weight="0.50"
android:layout_width="0dp" android:layout_height="fill_parent">
<FrameLayout
android:layout_width="fill_parent" android:layout_gravity="center|center_vertical"
android:id="@+id/openscanbarcode"
android:layout_height="fill_parent" android:background="#ffffff">

<ImageView
android:layout_width="fill_parent" android:scaleType="centerCrop"
android:layout_height="fill_parent" android:src="@drawable/bgbarcodescanner" />
<ImageView
android:layout_width="fill_parent" android:scaleType="centerInside" android:padding="8dp"
android:layout_height="fill_parent" android:src="@drawable/handgqscanner" android:layout_marginBottom="20dp" />
<TextView
android:layout_width="fill_parent" android:layout_gravity="bottom" android:gravity="center|center_vertical"
android:paddingTop="9dp" android:paddingBottom="10dp" android:paddingLeft="5dp" android:paddingRight="5dp"
android:lineSpacingExtra="8dp"
android:layout_height="wrap_content" android:background="#88000000" android:tag="persian" android:textSize="15sp"
android:textColor="#ffffff" android:text="اسکن برچسب بازاردان" />

</FrameLayout>
</com.balysv.materialripple.MaterialRippleLayout>

<com.balysv.materialripple.MaterialRippleLayout
app:mrl_rippleOverlay="true"
app:mrl_rippleColor="#ffa911"
app:mrl_rippleAlpha="0.3"
app:mrl_rippleDelayClick="false"
app:mrl_rippleHover="true"
app:mrl_rippleDuration="400"
app:mrl_rippleFadeDuration="250" android:layout_gravity="left" android:layout_weight="0.50"
android:layout_width="0dp" android:layout_height="fill_parent">
<FrameLayout
android:layout_width="fill_parent" android:layout_gravity="center|center_vertical"
android:id="@+id/openidbzpfinder"
android:layout_height="fill_parent" android:background="#ffffff">
<ImageView
android:layout_width="fill_parent" android:scaleType="centerCrop"
android:layout_height="fill_parent" android:src="@drawable/bgidfinder" />
<ImageView
android:layout_width="fill_parent" android:scaleType="centerInside" android:padding="8dp"
android:layout_height="fill_parent" android:src="@drawable/atbzp" android:layout_marginBottom="20dp" />
<TextView
android:layout_width="fill_parent" android:layout_gravity="bottom" android:gravity="center|center_vertical"
android:paddingTop="9dp" android:paddingBottom="10dp" android:paddingLeft="5dp" android:paddingRight="5dp"
android:lineSpacingExtra="8dp"
android:layout_height="wrap_content" android:background="#88000000" android:tag="persian" android:textSize="15sp"
android:textColor="#ffffff" android:text="شناسه یاب بازاردان" />

</FrameLayout>
</com.balysv.materialripple.MaterialRippleLayout>

</LinearLayout>


<LinearLayout
android:layout_width="fill_parent"
android:orientation="horizontal"
android:layout_height="150dp"
android:gravity="left"
android:baselineAligned="false" >
<com.balysv.materialripple.MaterialRippleLayout
app:mrl_rippleOverlay="true"
app:mrl_rippleColor="#ffa911"
app:mrl_rippleAlpha="0.3"
app:mrl_rippleDelayClick="false"
app:mrl_rippleHover="true"
app:mrl_rippleDuration="400" android:layout_gravity="left"
app:mrl_rippleFadeDuration="250" android:layout_weight="0.50"
android:layout_width="0dp" android:layout_height="fill_parent">
<FrameLayout
android:layout_width="fill_parent" android:layout_gravity="center|center_vertical"
android:id="@+id/openmaybeknow"
android:layout_height="fill_parent" android:background="#ffffff">

<ImageView
android:layout_width="fill_parent" android:scaleType="centerCrop"
android:layout_height="fill_parent" android:src="@drawable/bgidfinder" />
<ImageView
android:layout_width="fill_parent" android:scaleType="centerInside" android:padding="8dp"
android:layout_height="fill_parent" android:src="@drawable/meybeknow" android:layout_marginBottom="20dp" />
<TextView
android:layout_width="fill_parent" android:layout_gravity="bottom" android:gravity="center|center_vertical"
android:paddingTop="9dp" android:paddingBottom="10dp" android:paddingLeft="5dp" android:paddingRight="5dp"
android:lineSpacingExtra="8dp"
android:layout_height="wrap_content" android:background="#88000000" android:tag="persian" android:textSize="15sp"
android:textColor="#ffffff" android:text="شاید بشناسید !" />

</FrameLayout>
</com.balysv.materialripple.MaterialRippleLayout>

<com.balysv.materialripple.MaterialRippleLayout
app:mrl_rippleOverlay="true"
app:mrl_rippleColor="#ffa911"
app:mrl_rippleAlpha="0.3"
app:mrl_rippleDelayClick="false"
app:mrl_rippleHover="true"
app:mrl_rippleDuration="400"
app:mrl_rippleFadeDuration="250" android:layout_gravity="left" android:layout_weight="0.50"
android:layout_width="0dp" android:layout_height="fill_parent">
<FrameLayout
android:layout_width="fill_parent" android:layout_gravity="center|center_vertical"
android:id="@+id/openmyfinger5km"
android:layout_height="fill_parent" android:background="#ffffff">
<ImageView
android:layout_width="fill_parent" android:scaleType="centerCrop"
android:layout_height="fill_parent" android:src="@drawable/bgbarcodescanner" />
<ImageView
android:layout_width="fill_parent" android:scaleType="centerInside" android:padding="8dp"
android:layout_height="fill_parent" android:src="@drawable/locationf3" android:layout_marginBottom="20dp" />
<TextView
android:layout_width="fill_parent" android:layout_gravity="bottom" android:gravity="center|center_vertical"
android:paddingTop="9dp" android:paddingBottom="10dp" android:paddingLeft="5dp" android:paddingRight="5dp"
android:lineSpacingExtra="8dp"
android:layout_height="wrap_content" android:background="#88000000" android:tag="persian" android:textSize="15sp"
android:textColor="#ffffff" android:text="۵ کیلومتری انگشتتان !" />

</FrameLayout>
</com.balysv.materialripple.MaterialRippleLayout>

</LinearLayout>

<com.balysv.materialripple.MaterialRippleLayout
android:layout_width="fill_parent" android:layout_height="wrap_content"
app:mrl_rippleOverlay="true"
app:mrl_rippleColor="#ffffff"
app:mrl_rippleAlpha="0.3"
app:mrl_rippleDelayClick="false"
app:mrl_rippleHover="true"
app:mrl_rippleDuration="400"
app:mrl_rippleFadeDuration="250" >
<FrameLayout
android:layout_width="fill_parent" android:id="@+id/amionbzardan"
android:layout_height="200dp">
<ImageView
android:layout_width="fill_parent" android:scaleType="centerCrop"
android:layout_height="fill_parent" android:src="@drawable/bgredcrystal" />
<ImageView
android:layout_width="fill_parent" android:src="@drawable/bgmyerondshadowtop" android:layout_gravity="top"
android:layout_height="100dp" android:scaleType="fitXY" />
<ImageView
android:layout_width="fill_parent" android:src="@drawable/bgmyerondshadow" android:layout_gravity="bottom"
android:layout_height="100dp" android:scaleType="fitXY" />
<LinearLayout
android:layout_width="fill_parent" android:orientation="vertical" android:layout_gravity="center|center_vertical"
android:layout_height="fill_parent" android:gravity="center|center_vertical" >

<ImageButton
android:layout_width="60dp"
android:background="@drawable/roundedbutton60"
android:src="@drawable/mycurentlocation"
android:scaleType="centerInside" android:layout_gravity="center|center_vertical"
android:padding="10dp"
android:layout_height="60dp" />

<TextView
android:layout_width="fill_parent" android:textSize="20sp" android:textColor="#fff"
android:layout_marginTop="10dp" android:text="آیا هم اکنون در محل بازاردانی هستید ؟!"
android:layout_height="wrap_content" android:layout_marginLeft="10dp" android:layout_marginRight="10dp"
android:gravity="center|center_vertical" android:layout_gravity="center|center_vertical" android:tag="persian" />

</LinearLayout>
</FrameLayout>
</com.balysv.materialripple.MaterialRippleLayout>




please help me , how to fix it ?!

Answer

It looks like that your are displaying Bitmaps in your adapter directly by using imageView.setImageBitmap. Instead you should use UniversalImageLoader. In ListViews bitmaps should not be displayed on Main thread instead should be loaded on background threads see the link https://github.com/nostra13/Android-Universal-Image-Loader