0

I am designing an app of which there is an index page that link to several content layouts, and each layout has an imagebutton in the middle of the screen. The code for the ImageButton is as follows:

<ImageButton
            android:id="@+id/image_button"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:adjustViewBounds="true"
            android:background="@drawable/transparent_btn"
            android:focusable="false"
            android:gravity="center"
            android:scaleType="fitCenter"
            android:src="@drawable/ice_cream400" />

The ice_cream400 is an png of 400*400px and around 148KB.

Question:

I always come across with problems about images.

The png are already put under the drawable-xhdpi folder as suggested from research as the system will shrink the size automatically.

I am running the app in real phone device and discover that from time to time loading the content layout takes a lot of time (around 2 sec). How could the performance be improved? Need fetching the dimension of the screen and scale down before import? (the imagebutton would occupy around 70% of the screen)

Thanks!

pearmak
  • 4,979
  • 15
  • 64
  • 122
  • Are you sure it's the images causing the problem? Have you tried profiling it with DDMS to verify? – Geobits Nov 08 '13 at 17:36
  • sorry...could you please tell me more about "DDMS" verification? – pearmak Nov 08 '13 at 17:52
  • [DDMS](http://developer.android.com/tools/debugging/ddms.html) is the debug service that comes with the SDK. Try using method profiling to see what method(s) are taking too much time. – Geobits Nov 08 '13 at 17:55
  • thanks...I have opened the DDMS and checked the method profiling...but what is going on there...the logcat writes Skipped 113 frames! The application may be doing too much work on its main thread. – pearmak Nov 09 '13 at 09:58

0 Answers0