From the discussion in the answer from @JarvanZhang , since the tab bar is placed at the bottom of the page the bar is represented by a BottomNavigationView
. I therefore need to apply the desired background style via a custom TabbedPage
renderer.
In the renderer, override OnElementChanged
as follows:
protected override void OnElementChanged(ElementChangedEventArgs<TabbedPage> e)
{
base.OnElementChanged(e);
if (e.NewElement == null) return;
// Identify first (only) bottom navigation view in collection of element children.
var bottomNavigationView = GetBottomNavigationView(ViewGroup);
// Apply a custom border style for the item background.
bottomNavigationView.ItemBackground =
Resources?.GetDrawable(Resource.Drawable.background_states, Context?.Theme);
}
where GetBottomNavigationView
is a method for traversing the tree of element children and needs to be separately implemented (left out here for brevity). The drawable resource background_states
is the selector used to apply different backgrounds depending on state.