Android Question Bottom navigation panel issues

Martin Larsen

Active Member
Licensed User
Like many apps my app has a button bar in the bottom of most screens for easy navigation. There are four buttons, one for each of the most used screens. The current screen is highlighted in the button bar.

This setup involves a few issues:

[I want the app it to be crossplatform as much as possible so whatever I do regarding the issues below it should be compatible with B4i if at all possible.]

1. Duplication
Now I simply copy & paste the panel in the designer and also the few lines in the designer scripts that place the buttons nicely. I also copy and paste the events from the buttons.
Are there better ways of doing this? Can I somehow share a panel including events between several activities?

2. Transitions between screens
a. Disable animations in code​

When the main activity starts I like the default animation. It looks good. However, when I navigate to the Home screen via the button bar, it looks bad. Is it possible to set Animation Duration in code? I can set it to zero in the designer, but then it also disables the initial animation which I do want to keep.

b. Seamless transitions​
Even with animations disabled there is a noticeable "flash" when moving between activities. The new activity slides in from the right. In other apps the transition is seamless. How is that done? With seamless I mean that there is sometimes a delay of the content itself in the activity, but the button bar is completely steady. It doesn't "flash".

If I instead of using the home button presses the back button the previous activity is shown instantly as it was before without animations etc. Can I somehow start the activity in the same way and state as pressing the back button?

3. Activity stack
Let's say I right after start press the second button to go to activity #2. If I press Back twice it first goes back to the Home activity, then exits the application. But if I press Home from activity #2 and then press Back I go back to #2. I have solved the problem with
B4X:
Dim jo As JavaObject
jo.InitializeContext
jo.RunMethod("finishAffinity", Null)
StartActivity(Main)
but it actually seems to make the transition more noticeable. Is there a better way to bypass the activity stack?

4. Single activity?
I think all the issues above could be solved by using a single activity and then load the respective layouts. It would also solve the problem with pre-loading a webview.

However, it seems contra intuitive to me with just a single activity. Are there any problems with this approach? (Apart from making the code less readable/maintainable). Is it widely used?
 

aeric

Well-Known Member
Licensed User
How if you create a main layout with 2 panels, for example top is 90% height and 10% height for the bottom panel for the buttons. Load different layout to the bigger panel.
 

Martin Larsen

Active Member
Licensed User
That is actually what I mean with a single activity app. But I would like to investigate other solutions first.
 

Martin Larsen

Active Member
Licensed User
Yes. Implement it in a class and create a class instance in each of the activities.
Cool. I will try that.

What about the seamless switch between activities? Ie. the button bar staying in place without "flashing" when a new activity is started?
 

José J. Aguilar

Well-Known Member
Licensed User
Implement it in a class and create a class instance in each of the activities
You can get some ideas from this post, to reuse your botton navigation panel
 

Martin Larsen

Active Member
Licensed User
I recommend you to use a single activity with multiple classes for your layout.
I was beginning to suspect this. Is this a generally recommended design pattern? It seems to solve many problems.

Does it also apply for B4i? I am using XUI.
 
Top