Breaking News
Home / Android / Android Snippets / How do you center an Image to display in a Splash Page in Android?

How do you center an Image to display in a Splash Page in Android?

Generally the splash page displays an image of the App on launch of the app. Most of time its just an single image that is intended to be displayed.Depending of the size of image and device it runs, it may not fit the screen fully and there may be space on right/bottom of screen, in other words its left aligned and is not equally spaced from the screen corner.

To have it display in the center, use the android:layout_gravity=”center” attribute as show below:

<ImageView
        android:id=”@+id/imageView1″
        android:layout_width=”wrap_content”
android:layout_height=”wrap_content”
android:layout_gravity=”center”
        android:src=”@drawable/loading_screen”/><!>

[pb_builder]

Check Also

How to check if an Android device can connect to Internet?

The following code snippet shows how to check if an Android device can connect to …

Leave a Reply