In my previous posts I explained you how to Implement Animated Screen in Android and Splash screen with Ken Burns view. In this post I will explain you how to show a random image in Splash screen when your Android app is launched every time. Which gives a Fresh look to your Android App users. And it is very easy to implement though.

Note:- If you want detailed explanation of code watch the Video Below

Procedure:

  • Open your existing Android studio project or create a new Android Studio Project.
  • Create a new Java Class with name Splashscreen . Now remove whole code in it except first line with your package name and paste below code into it after the first line.

 

  • Then create new XML Layout with Name activity_splashscreen. Remove complete code in it  and paste below code into it.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:background="#e01a35"
tools:context=".Splashscreen" >

<ImageView
android:id="@+id/imageView2"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_centerHorizontal="true" />

</RelativeLayout>
  • Next open your Androidmanifest.xml and add Splashscreen activity there and make in launcher in intent-filter like below.
<activity
android:name=".Splashscreen"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
  • If you have another activity as launcher change it to default. For example Mainactivity
  • Finally copy splash_image1, splash_image2, splash_image3 to drawable folder either in PNG or JPG.
  • Now export to apk or run app in your device or emulator using ADB.

 

Download Source code from below link.

[ihc-hide-content ihc_mb_type=”show” ihc_mb_who=”reg” ihc_mb_template=”1″ ]Download our app from PlayStore and go to categories tab and Tap on Downloads to get Source code.[/ihc-hide-content]