Android Question [B4xpages] Splash - how to remove title bar from mainpage only?

Reminisce

Active Member
I'd like to remove title bar from the mainpage and leave the title bar for all other pages active.
I want to use the mainpage as a splash for my app, and it's unprofessional for a splash screen to have a title bar.
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
The attached project implements a splash screen in the main activity. B4XPages is contained in Activity2, which includes the action bar.

The difficult part is in the switch between the full screen activity to the non-full screen activity. The size of the activity will not be correct. The code in this example takes care of it.


Edit: the attached project includes the fix discussed below.

Cross platform implementation: https://www.b4x.com/android/forum/threads/b4x-b4xpages-splash-screen.120851/post-755510
 

Attachments

  • Project.zip
    22.7 KB · Views: 268
Last edited:
Upvote 0

agraham

Expert
Licensed User
Longtime User
I'm probably being an idiot and missing the glaringly obvious but how is the Main activity shown full screen with these attributes? :confused:
B4X:
#Region  Activity Attributes
    #FullScreen: False
    #IncludeTitle: True
#End Region
This also had me wondering what was happening for a moment or two as well!
B4X:
Wait For ime_HeightChanged (NewHeight As Int, OldHeight As Int)
I'm getting too old and sick to keep up with this :(
 
Last edited:
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
2. The IME is required to handle the change in the activity height that happens after the activity is created. There is an edge case here.
B4X:
Sub Activity_Create(FirstTime As Boolean)
    Dim ime As IME
    ime.Initialize("ime")
    ime.AddHeightChangedEvent
    Dim pm As B4XPagesManager
    pm.Initialize(Activity)
    CorrectHeight = 100%y
    Wait For ime_HeightChanged (NewHeight As Int, OldHeight As Int)
    CorrectHeight = NewHeight
LogColor("CorrectHeight " & CorrectHeight, Colors.Blue) ' <----
End Sub

Sub ime_HeightChanged (NewHeight As Int, OldHeight As Int)
    LogColor("ime_HeightChanged", Colors.Blue) ' <----
End Sub

I was "testing", because I wasn't sure that Sub ime_HeightChanged would be triggered given the existence of the wait for.

Neither log executed. ?


I used B4A 10 Beta (I know there is the new version).
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
1595491403107.png


Ehm... I see... the edges (reading your post I had thought of a small red square - I wasn't following the matter very much, obviously the square serves to highlight the limits, now I'm "more concentrated" ? .

However I don't understand why those logs are not executed ?
 
Upvote 0

agraham

Expert
Licensed User
Longtime User
However I don't understand why those logs are not executed
That was why I was wondering about the line
B4X:
Wait For ime_HeightChanged (NewHeight As Int, OldHeight As Int)
The Wait For pre-empts the event Sub which is never run, but I still don't understand the mechanism that returns the event Sub parameters as apparently multiple return values. I need to look at the generated Java code.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
However I don't understand why those logs are not executed
It depends on the device behavior. On some devices the activity will start with the correct height and on other devices it will be updated a few milliseconds after the activity was created.
The Wait For pre-empts the event Sub which is never run, but I still don't understand the mechanism that returns the event Sub parameters as apparently multiple return values. I need to look at the generated Java code.
There is nothing special here. Wait For can be used to catch events.
 
Upvote 0

agraham

Expert
Licensed User
Longtime User
There is nothing special here.
This is the special bit.
Wait For can be used to catch events.
I understand the mechanism of Wait For with Resumable Subs. However I had an unknown unknown (© Donald Rumsfeld) in that I didn't understand the mechanism for catching events and returning their multiple parameters as a list of results.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
This means that the code needs to be improved.

Please change Activity2 code:
B4X:
Sub Activity_Create(FirstTime As Boolean)
    Dim ime As IME
    ime.Initialize("ime")
    ime.AddHeightChangedEvent
    Dim pm As B4XPagesManager
    pm.Initialize(Activity)
    CorrectHeight = 100%y
    Log("A: " & DateTime.Now)
    Wait For ime_HeightChanged (NewHeight As Int, OldHeight As Int)
    Log("B: " & DateTime.Now & ", " & NewHeight & ", " & OldHeight)
    CorrectHeight = NewHeight
End Sub
and post the logs.
 
Upvote 0
Top