B4X Programming – How to build splash screen in B4A and B4i

ADVERTISEMENT

How to build splash screen in B4A and B4i

Splash screens are have become integral part of an app or software. They enforce the brand identity of an organisation and sometimes help to put quick information to the users.  Applications like Facebook, Twitter, Dropbox on launch display a small logo to before the main interface launches. Some applications.

Whiles some application use logo as their splash screen, some uses the splash screen to keep the user updated whiles the app loads the necessary resources needed for the application to work when it starts. Some applications will also show progress bar on the splash screen to show the level of progress.

 

Below is an example of splash screen from Twitter and Facebook

B4X Programming - How to build splash screen in B4A and B4i 1

STEPS IN BUILDING SPLASH SCREEN

  1. Open the designer menu and create 2 layouts namely splashcreen and home
  2. Add imageview to the the splashcreen layout and add your logo or to it. Feel free to explore, you can add labels and design it any way you want.
  3. Design your home layout as you so wish
  4. Next go back to the IDE, under main, load the splashcreen layout.
  5. Create a new activity by going to Menu – Add New Module – Activity Module. Name it actHome and load the home layout as well.

Using Sleep method, we specify the time in milliseconds which the app will hold (pause) before continuing. Lets use 3000 (3 seconds)

Sub Activity_Create(FirstTime As Boolean)
	Activity.LoadLayout("splashcreen")
	
	Sleep(3000)
	
	StartActivity(actHome)
	Activity.Finish

End Sub
 

Using Timer method. We declare Timer object in the process global, we then initialize the timer with the time and enable the timer on activity start.

in the Timer subroutine, we then place place the code to start our home activity.

Sub Process_Globals
	Dim tm As Timer
End Sub

Sub Globals


End Sub

Sub Activity_Create(FirstTime As Boolean)
	Activity.LoadLayout("splashcreen")
	
	'You can choose to use 1000 interval that is 1 seconds but needs checking the count
	tm.Initialize("tm",3000)
	tm.Enabled = True

End Sub

Sub tm_Tick
	StartActivity(actHome)
	Activity.Finish
End Sub
 

Related Posts

4 Responses

Leave a Reply

Your email address will not be published. Required fields are marked *

Subscribe to our Youtube Channel

Be informed when we upload new videos and source codes