Selected tab icon not visible in tabbed page

Thombre, Ashish 130 Reputation points
2024-04-01T08:33:04.75+00:00

Issues-

  1. Selected tab(Resources) icon shows blank, icon should be visible( ref screenshots)
  2. Previously selected tab(Details) icon color changes to black its should be white (ref screenshots)

Currently using below code for custom handler

public class ScrollableTabbedViewHandler : TabbedViewHandler

{
[Obsolete]

public override void UpdateValue(string property)

{

    base.UpdateValue(property);

    var tabs = Platform.CurrentActivity?.FindViewById<FragmentContainerView>(Microsoft.Maui.Resource.Id

        .navigationlayout_toptabs);

    var tabLayout = tabs?.GetChildAt(0);

    if (tabLayout is TabLayout layout)

    {

        layout.TabMode = TabLayout.ModeScrollable;

        layout.SetSelectedTabIndicatorColor(Color.FromRgb(44,82,52).ToAndroid());


      

        layout.SetSelectedTabIndicatorHeight(12);

        for (int i = 0; i < layout.TabCount; i++)

        {

            TabLayout.Tab? tab = layout.GetTabAt(i);

            TabLayout.TabView? view = tab?.View;

            for (int j = 0; j < (view?.ChildCount ?? 0); j++)

            {

                var child = view?.GetChildAt(j);

                if (child is TextView tv)

                {

                    tv.SetAllCaps(false);

                }

            }

        }

    }

}
}


In mauiprogram.cs class using below code

 ConfigureMauiHandlers((handlers) =>

  {

  handlers.AddHandler(typeof(TabbedPage), typeof(Platforms.Android.ScrollableTabbedViewHandler));
}



2024-04-01_13h45_24

Developer technologies | .NET | .NET MAUI
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.