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!