i recently have been experiencing with lag when i run my program, one of my activity has 7 images and im planning to add more however when i start to scroll down the whole thing lags, i dont know if its because of the action bar that i have hidden in the xml(i hid it because i dont know how to remove it from the activity), im hoping that you guys can tell me how to fix this issue (lag issue).
<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=".EX" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="688dp" >
<ImageView
android:id="@+id/border"
android:layout_width="wrap_content"
android:layout_height="7dp"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:src="@drawable/greenborder" />
<ImageView
android:id="@+id/imageView1"
android:layout_width="125dp"
android:layout_height="125dp"
android:layout_alignParentLeft="true"
android:layout_below="@+id/imageView2"
android:layout_marginLeft="40dp"
android:layout_marginTop="50dp"
android:clickable="true"
android:src="@drawable/ss" />
<ImageView
android:id="@+id/imageView3"
android:layout_width="125dp"
android:layout_height="125dp"
android:layout_alignParentRight="true"
android:layout_alignTop="@+id/imageView1"
android:layout_marginRight="40dp"
android:clickable="true"
android:src="@drawable/cht" />
<ImageView
android:id="@+id/imageView4"
android:layout_width="125dp"
android:layout_height="125dp"
android:layout_alignLeft="@+id/imageView1"
android:layout_below="@+id/imageView1"
android:layout_marginTop="28dp"
android:clickable="true"
android:src="@drawable/ags" />
<ImageView
android:id="@+id/imageView5"
android:layout_width="125dp"
android:layout_height="125dp"
android:layout_alignLeft="@+id/imageView3"
android:layout_alignTop="@+id/imageView4"
android:clickable="true"
android:src="@drawable/as" />
<ImageView
android:id="@+id/imageView6"
android:layout_width="125dp"
android:layout_height="125dp"
android:layout_alignLeft="@+id/imageView4"
android:layout_below="@+id/imageView4"
android:layout_marginTop="27dp"
android:clickable="true"
android:src="@drawable/ly" />
<ImageView
android:id="@+id/imageView7"
android:layout_width="125dp"
android:layout_height="125dp"
android:layout_alignLeft="@+id/imageView5"
android:layout_alignTop="@+id/imageView6"
android:clickable="true"
android:src="@drawable/co" />
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/imageView3"
android:layout_centerHorizontal="true"
android:layout_marginBottom="9dp"
android:text="Select a category:"
android:textAppearance="?android:attr/textAppearanceMedium" />
<ImageView
android:id="@+id/imageView8"
android:layout_width="125dp"
android:layout_height="125dp"
android:layout_alignLeft="@+id/imageView6"
android:layout_below="@+id/imageView6"
android:layout_marginTop="27dp"
android:clickable="true"
android:src="@drawable/fy" />
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/imageView8"
android:layout_alignLeft="@+id/imageView7"
android:layout_alignRight="@+id/imageView7"
android:text="More available soon"
android:textAppearance="?android:attr/textAppearanceMedium" />
</RelativeLayout>
</ScrollView>
logcat:
06-30 18:05:24.908: E/LocSvc_IzatApiV02(584): W/virtual int izat_core::IzatApiV02::injectLocation(GpsExtLocation):665]: error! inject position failed
06-30 18:05:24.918: E/LocSvc_ApiV02(584): W/virtual loc_api_adapter_err LocApiV02::injectPosition(double, double, float):492]: error! status = eLOC_CLIENT_FAILURE_INVALID_PARAMETER, inject_pos_ind.status = UNKNOWN
06-30 18:05:24.968: I/GCoreUlr(6145): Successfully inserted location
06-30 18:05:24.968: I/GCoreUlr(6145): Not calling LocationReportingService, hasMoved: false, elapsed millis: 2176457, request: Phone
06-30 18:05:28.802: I/Choreographer(8748): Skipped 39 frames! The application may be doing too much work on its main thread.
06-30 18:05:29.483: I/Choreographer(8748): Skipped 40 frames! The application may be doing too much work on its main thread.
06-30 18:05:30.154: I/Choreographer(8748): Skipped 39 frames! The application may be doing too much work on its main thread.
06-30 18:05:30.834: I/Choreographer(8748): Skipped 40 frames! The application may be doing too much work on its main thread.
06-30 18:05:31.495: I/Choreographer(8748): Skipped 39 frames! The application may be doing too much work on its main thread.
06-30 18:05:32.166: I/Choreographer(8748): Skipped 39 frames! The application may be doing too much work on its main thread.
There are certain things you can do for your lag issues:
You can scale down your pictures.
For this I would strongly recommend reading this Loading Large Bitmaps Efficiently
Make a new folder in your res folder named drawable-nodpi and move all your png(your images) resources there!
Resize your images from 2048 x 2048 to a lower resolution.