I want to customise the ActionBar on Android in a TabbedPage to add a logo at the left of the action bar.
What event do I override and how do I get access to the ActionBar?
I'm thinking something like this:
[assembly: ExportRendererAttribute(typeof(TabbedPage), typeof(CustomTabbedPage))]
public class CustomTabbedPage : TabbedRenderer
{
protected override void OnAttachedToWindow()
{
base.OnAttachedToWindow();
var actionBar = ????
}
}
Are there any examples of custom tabbed pages?
Posts
I've got this working without customising TabbedPage, by setting a theme for my Activity.
Not sure why it was not displaying the logo on the tabbed page before.
Still curious about best practise for customizing a TabbedPage anyway.
I figured out what makes my logo appear and disappear on the Android ActionBar.
Adding a toolbar item:
Makes my logo appear.
If I don't add any any toolbar items, it does not appear.
Of course the toolbar items don't actually appear anyway.
@ is up with that?
The prerelease of 1.2.2 seems to fix most of my Android problems. Toolbar items work correctly and, more importantly, it does not crash when using a TabbedPage as my main page.
One problem I still have is that Forms keeps setting the ShowHomeAsUp flag in the Android ActionBar.
I set the ActionBar display options from inside OnAppearing:
ActionBar.DisplayOptions = ActionBarDisplayOptions.UseLogo | ActionBarDisplayOptions.ShowHome;
But Forms sets the ShowHomeAsUp flag when it displays the page.
Does anyone know how to prevent it from doing that or where to hook some code just after it displays a page?
@AlanTonisson: Do you find a possibility to change the visibility of the home icon dynamically?
@Charlenni
Have you tried
ActionBar.SetDisplayShowHomeEnabled(true)
andActionBar.SetDisplayShowHomeEnabled(false)
?They work for me.
They work for me too, but I had to place them in the OnDraw function of the page. It would be better, if I had find a place inside NavigationPage. But there they don't work. It seems, that XF set the back button in Android in Page and in iOS in NavigationPage
I came across the same problem with logo for the ActionBar. I used Alan's recommendation, and the logo appeared when the page loaded first time, but then it disappeared once I clicked on any tabs.
This code works for me.
` public class CustomTabbedRenderer : TabbedRenderer
{
I used the TabSelected event handler to keep the logo on the ActionBar.
Use a custom navigation renderer, and the basics are:
Use a custom navigation renderer, and the basics are:
Use a custom navigation renderer, and the basics are: