B4A Library Splash Screen Library with Slide & Fade Out

Added Feb 20th, 2014 - Version 1.02
This library displays a splash screen and then removes it by fading it out, just removing it or sliding it off the screen in any direction, your choice.

This new library was based on my SplashFade class, that I had posted some time back. It requires the Phone and JavaObjects libraries provided with B4A 3.2. It will work in previous versions of B4A, provided you have these libraries in the Xtralibs or Internal library folder . Supports Android 2.2+ versions. There are many improvements above the class code as to how it works and the speed. It also now includes a callback to the Activity to let the Activity know the screen slide or fade has completed. Instead of "Left", Up, etc., pass "" for the fade.

This version also includes a new Random feature. If set to True(the last parameter), it will randomly choose to fade, slide up, down, left, etc.

The library is attached.

Special thanks to Stevel05 for helping me sort this out! This library has broader support due to his work and help. Thanks Steve!

Uses Phone & JavaObjects Libraries. NOTE: You do not need to select these in the Libraries TAB, just make sure they are in your Xtralibs folder.

Code Sample:
B4X:
Sub Globals
    Dim MyFade As SplashFade
End Sub
 
Sub Activity_Create(FirstTime AsBoolean)
    Activity.LoadLayout("YourLayoutFile")
    'Place this line below the Activity.LoadLayout or after the last view you add by code.
    MyFade.Initialize(Activity, Me, "yourimage.jpg", Gravity.FILL, 3000, 100, "Left", False)
End Sub
 
Sub Splash_Complete
    'Add this sub if you need to know when the splash has completed
End Sub
 

Attachments

  • SplashFadeSlideLibrary.zip
    5 KB · Views: 1,841
Last edited:

LucaMs

Expert
Licensed User
Longtime User
Hi, Margret, thanks for sharing.

(I have not tried it yet but I will)

Two small (?) questions:

why it needs Phone and JavaObjects libraries? It would not be sufficient to use one Animation library?

why I don't need to reference them in the Tab Libraries?

Thanks again
 

margret

Well-Known Member
Licensed User
Longtime User
It is because the older versions of Android does not support some features but they can be performed another way. The features that support the older versions does not look very good on the newer models. So, to make it more compatible with the new and old, both ways are included. The phone lib is used to determine the current SDK level.
 

LucaMs

Expert
Licensed User
Longtime User
It is because the older versions of Android does not support some features but they can be performed another way. The features that support the older versions does not look very good on the newer models. So, to make it more compatible with the new and old, both ways are included. The phone lib is used to determine the current SDK level.


Thanks
 

LucaMs

Expert
Licensed User
Longtime User
I already have one "home made" splashscreen, so I tried the library with the same picture but it looks distorted.

[UPDATED] my pic is in a panel that i resize in the code. It is squared, so THERE ARE NO PROBLEMS in your lib :)

In addition, the image is a png with transparent background, so if I press a visible button, it "responds"
 

LucaMs

Expert
Licensed User
Longtime User
Without reading the help (lazy!) I had imagined that the parameter FadeDelay acting also on the Slide.

Can I suggest to add a SlideDelay parameter? (lazy and greedy :))

Try this one attached. It's all the same but the slide will look and use the FadeDelay. If you set the FadeDelay to 0, no slide will take place, the image will just clear after the specified time.


No sooner said than done!

(I have not become good at English, I found this to translate an Italian way of saying ;))
 

Douglas Farias

Expert
Licensed User
Longtime User
margaret how can i make to user cant click at splash ?
for exemple when the splash is in the screnn the user can click at buttons behind the splash

i set 5000 time but users can click in this 5000 normal *-*
 

luke2012

Well-Known Member
Licensed User
Longtime User
Added Feb 20th, 2014 - Version 1.02
This library displays a splash screen and then removes it by fading it out, just removing it or sliding it off the screen in any direction, your choice.

This new library was based on my SplashFade class, that I had posted some time back. It requires the Phone and JavaObjects libraries provided with B4A 3.2. It will work in previous versions of B4A, provided you have these libraries in the Xtralibs or Internal library folder . Supports Android 2.2+ versions. There are many improvements above the class code as to how it works and the speed. It also now includes a callback to the Activity to let the Activity know the screen slide or fade has completed. Instead of "Left", Up, etc., pass "" for the fade.

This version also includes a new Random feature. If set to True(the last parameter), it will randomly choose to fade, slide up, down, left, etc.

The library is attached.

Special thanks to Stevel05 for helping me sort this out! This library has broader support due to his work and help. Thanks Steve!

Uses Phone & JavaObjects Libraries. NOTE: You do not need to select these in the Libraries TAB, just make sure they are in your Xtralibs folder.

Code Sample:
B4X:
Sub Globals
    Dim MyFade As SplashFade
End Sub

Sub Activity_Create(FirstTime AsBoolean)
    Activity.LoadLayout("YourLayoutFile")
    'Place this line below the Activity.LoadLayout or after the last view you add by code.
    MyFade.Initialize(Activity, Me, "yourimage.jpg", Gravity.FILL, 3000, 100, "Left", False)
End Sub

Sub Splash_Complete
    'Add this sub if you need to know when the splash has completed
End Sub

Hi @margret !
Is it possible to integrate the attached scaling code ?

http://www.b4x.com/android/forum/threads/live-wallpaper-background.24907/#post-144401
 

margret

Well-Known Member
Licensed User
Longtime User
OK, I have included it. I have not done much testing, so let me know if you find any issues. The way you get it to resize the image, is to set the gravity to: Gravity.CENTER. That is the only one that will call the internal resize code.

B4X:
MyFade.Initialize(Activity, Me, "splash.jpg", Gravity.CENTER, 3000, 100, "", False)

The modified library is attached.
 

Attachments

  • SplashFadeSlideLibrary.zip
    5.7 KB · Views: 692

Douglas Farias

Expert
Licensed User
Longtime User
@Margaret thx this is working fine.
one question, its posible to make a fade in ? when the app start show my logo with fade in later 3 seconds show fade out *-* ?
 
Top