Listing 122 splashxml defines the layout of the applications splash screen

<?xml version="1.0" encoding="utf- 8 " ?>

<LinearLayout xmlns:android="" android:orientation="vertical" android:layout_width="fill_parent"

android:layout_height="fill_parent" >

<ImageView android:layout_width="fill_parent" android:layout_height="fill_parent android:scaleType="fitCenter" android:src="@drawable/android" />


The splash.xml layout contains a single ImageView O, set to fill the entire screen. The source image for this view is defined as the drawable resource ©, named android. Note that this is simply the name of the file (minus the file extension) in the drawable folder, as shown earlier.

Now we must use this layout in an Activity. Aside from the referencing of an image resource from the layout, this is really not that interesting. Figure 12.5 shows the splash screen running on the Android Emulator.

O Full screen


Image reference

Figure 12.5 Splash screen

Of interest to us is the code that creates the splash page functionality. This code is shown in listing 12.3.

0 0

Post a comment