xamarin-forms-tab-badge
xamarin-forms-tab-badge copied to clipboard
[Legacy] Bagde icon does not work when the tabbed page is not the first page (main page)
I have modify your sample to first start on a page with a button. When we click on the bouton it launches the tabbed page
In this case, the tab badge are not visibles.
In this case, the _tabLinearLayout have not children.
I am using the case legacy because my application is inherit form FormsApplicationActivity. and launch the projet Plugin.Badge.Sample.Droid.Legacy
How can we resolve it ?
I have debugged a little and the issue seems to be in
_tabLinearLayout = _tabLinearLayout ?? (rootGroup.GetChildAt(i) as ViewGroup)?.FindChildOfType<HorizontalScrollView>()?.FindChildOfType<LinearLayout>();
the _tabLinearLayout never has children !! Why ???
Thank for your anser .
I have attached the sample android i have modified and snapshots of the screens
I have continued to debugged 👍 this problème comes from the ActionBarContainer.
When, the tabbedPage is the main page :
- the ActionBarContainer has 3 childs ( ActionBarView, ActionBarContextView and the ScollingTabContainerView)
When the TabbedPage is in the secondpage :
- the ActionBarContainer has 2 childs only ( ActionBarView, ActionBarContextView ) the ScollingTabContainerView is not Present !!!
Why ?
I have found. the ScollingTabContainerView is not here because the tabbedPage is not visible. So during, the navigation in the hierachy we are in the tree of the first page ( main page) not in the tree of the second page. So we have to wait a little before adding the bagdes
i have juste add a delay on the LegacyBadgedTabbedRenderer class private async void OnAppearing(object sender, EventArgs e) { Element.Appearing -= OnAppearing; await Task.Delay(1000); IViewParent root = ViewGroup;
@viviFrom13 Nice find, could you check if a shorter delay works (200ms)? Or maybe another page lifecycle event which can be used?
The delay depends of the loading time of the window. For my own application i need a delay of 3000 :(
If i tried to use another event like focused by i never found someting that working.
Do you have another idea ?
@viviFrom13 is this still an issue?