only find that on customizing tabbar on android
.ConfigureMauiHandlers(handlers => {
#if __ANDROID__
handlers.AddHandler(typeof(Shell), typeof(cshell));
#endif
});
public class cshell : ShellRenderer
{
protected override IShellItemRenderer CreateShellItemRenderer(ShellItem shellItem)
{
return new CustomShellItemRenderer(this);
}
}
internal class CustomShellItemRenderer : ShellItemRenderer
{
public CustomShellItemRenderer(IShellContext context) : base(context)
{ }
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
var view = base.OnCreateView(inflater, container, savedInstanceState);
if (Context is not null && ShellItem is TabBar tabbar)
{
var rootLayout = new FrameLayout(Context)
{
LayoutParameters = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent)
};
rootLayout.AddView(view);
const int middleViewSize = 150;
var middleViewLayoutParams = new FrameLayout.LayoutParams(
ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent,
GravityFlags.CenterHorizontal | GravityFlags.Bottom)
{
BottomMargin = 100,
Width = middleViewSize,
Height = middleViewSize
};
var middleView = new Button(Context) { LayoutParameters = middleViewLayoutParams };
rootLayout.AddView(middleView);
return rootLayout;
}
return view;
}
}