Android Question Best way to do a splash screen at app startup

Kevin Hartin

Active Member
Licensed User
What is the best way to do a splash screen?
  1. Use a panel in main that goes invisible after a while or on click
  2. Create an activity that is called from main at end of Activity_Create
  3. Some other way
My app is a OSMDroid tour app that the main layout is all built in Activity_Create rather than the designer. If this makes a difference...

Thanks,
Kev
 

Scantech

Well-Known Member
Licensed User
Longtime User
This is the way i do it. You can use a Timer to set the Image to false after certain amount of time.
I use 3 doevents.. cause some device will not display the image with less then 3.
Also, might want to use BringtoFront in case you load other layouts.
B4X:
Sub Activity_Create(FirstTime As Boolean)
        LoadSplashVersion
        DoEvents: DoEvents: DoEvents              
end sub

B4X:
Sub LoadSplashVersion

    imvSplash.Initialize("")
    Activity.AddView(imvSplash, 0, 0, 250dip, 50dip)        'originally at 250dip, 50dip
  
    imvSplash.Left             = (Activity.Width - imvSplash.Width)   /2
    imvSplash.Top              = (Activity.Height - imvSplash.Height) /2
  
    imvSplash.Gravity         = Gravity.FILL

  
    imvSplash.Bitmap         = LoadBitmap(File.DirAssets, "CarGaugeSplash2.png")
    imvSplash.Visible         = True
  

End Sub
 
Upvote 0
Top