Friday, 25 January 2019

Android Bottom Tabs

After Release of Xamarin Forms 3.x now we can set tab to bottom in android platform.


Code Behind :


    using Xamarin.Forms.PlatformConfiguration.AndroidSpecific;

 
 On<Android>().SetToolbarPlacement(ToolbarPlacement.Bottom);

OR 
 
   On<Xamarin.Forms.PlatformConfiguration.Android>().SetToolbarPlacement(ToolbarPlacement.Bottom);


From XAML :
 
 <?xml version="1.0" encoding="utf-8"?>
 <TabbedPage xmlns="http://xamarin.com/schemas/2014/forms"
 xmlns:android="clr-namespace:Xamarin.Forms.PlatformConfiguration.AndroidSpecific;assembly=Xamarin.Forms.Core"
 android:TabbedPage.ToolbarPlacement="Bottom"
example
 
Lets add a TabbedPage and include android:TabbedPage.ToolbarPlacement="Bottom" in the head of Page as shown below in XAML code.

 <?xml version="1.0" encoding="utf-8" ?>
 <TabbedPage xmlns="http://xamarin.com/schemas/2014/forms"
 xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
 x:Class="App1.TabbedPage1"
 xmlns:android="clr-namespace:Xamarin.Forms.PlatformConfiguration.AndroidSpecific;assembly=Xamarin.Forms.Core"
 android:TabbedPage.ToolbarPlacement="Top"
>
 
 <!--Pages can be added as references or inline-->
 <ContentPage Title="Tab 1" />
 <ContentPage Title="Tab 2" />
 <ContentPage Title="Tab 3" />
 </TabbedPage> 

Here, We have three options to set the position of Tabbar in android. i.e. Top, Bottom and Default.

 android:TabbedPage.ToolbarPlacement="Top"



sets the Tabbar to appear at the top whereas ,

 android:TabbedPage.ToolbarPlacement="Bottom"



No comments:

Post a Comment

All About .NET MAUI

  What’s .NET MAUI? .NET MAUI (.NET Multi-platform App UI) is a framework for building modern, multi-platform, natively compiled iOS, Androi...

Ads2