I have a ContentPage
(that is a content of the sub-classed Shell
class) which, when viewed requires a back button with a specific string text to be present in the navigation bar.
<ContentPage
....>
<Shell.NavBarIsVisible>True</Shell.NavBarIsVisible>
<Shell.BackgroundColor>Black</Shell.BackgroundColor>
<Shell.BackButtonBehavior>
<BackButtonBehavior IsEnabled="True"
TextOverride="A" />
</Shell.BackButtonBehavior>
.....
</ContentPage>
The back button with the required text is displayed as expected in the navigation bar, but the text is not quite in the required font size.
As always with such problems, I attempted to resolve the issue by using a custom shell renderer (as seen below), but I am not able to fathom the way to alter the font size of the text of the back button.
class ShellRenderer
: ShellRenderer
{
public ShellRenderer
(Context context) : base(context) { }
protected override IShellToolbarAppearanceTracker
CreateToolbarAppearanceTracker()
{
return new CustomToolbar(this);
}
public class CustomToolbar
: ShellToolbarAppearanceTracker
{
public CustomToolbar
(IShellContext context) : base(context)
{
}
public override void SetAppearance
(AndroidX.AppCompat.Widget.Toolbar toolbar,
IShellToolbarTracker toolbarTracker,
ShellAppearance appearance)
{
base.SetAppearance
(toolbar, toolbarTracker, appearance);
// How do you increase the font size of the back button??
}
}
}
Thanks in advance.
Read more here: https://stackoverflow.com/questions/66338734/altering-the-font-size-and-other-font-formatting-attributes-of-the-shell-class
Content Attribution
This content was originally published by hecate at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.