/// <inheritdoc/>
[EditorBrowsable(EditorBrowsableState.Never)]
- public override void OnRelayout(Vector2 size, RelayoutContainer container)
+ public new string Text
{
- base.OnRelayout(size, container);
- UpdateSizeAndSpacing();
+ get
+ {
+ return base.Text;
+ }
+ set
+ {
+ base.Text = value;
+ UpdateSizeAndSpacing();
+ }
+ }
+
+ /// <inheritdoc/>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public new string IconURL
+ {
+ get
+ {
+ return base.IconURL;
+ }
+ set
+ {
+ base.IconURL = value;
+ UpdateSizeAndSpacing();
+ }
}
/// <inheritdoc/>
if (tabButtonStyle != null)
{
- // Icon and Text
- if (!isEmptyIcon && !isEmptyText)
+ Padding = tabButtonStyle.Padding;
+
+ // Text only
+ if (isEmptyIcon && !isEmptyText)
{
if (tabButtonStyle.Size != null)
{
HeightSpecification = (int)tabButtonStyle.Size.Height;
}
- Padding = tabButtonStyle.Padding;
+ if ((tabButtonStyle.Text != null) && (tabButtonStyle.Text.PixelSize != null) && (tabButtonStyle.Text.PixelSize.Normal != null))
+ {
+ TextLabel.PixelSize = (float)tabButtonStyle.Text.PixelSize.Normal;
+ }
}
// Icon only
else if (!isEmptyIcon && isEmptyText)
HeightSpecification = (int)tabButtonStyle.SizeWithIconOnly.Height;
}
- Padding = tabButtonStyle.PaddingWithIconOnly;
-
if (tabButtonStyle.IconSizeWithIconOnly != null)
{
Icon.WidthSpecification = (int)tabButtonStyle.IconSizeWithIconOnly.Width;
Icon.HeightSpecification = (int)tabButtonStyle.IconSizeWithIconOnly.Height;
}
}
- // Text only
- else if (isEmptyIcon && !isEmptyText)
+ // Icon and Text
+ else if (!isEmptyIcon && !isEmptyText)
{
- if (tabButtonStyle.SizeWithTextOnly != null)
+ if (tabButtonStyle.SizeWithIcon != null)
{
- WidthSpecification = (int)tabButtonStyle.SizeWithTextOnly.Width;
- HeightSpecification = (int)tabButtonStyle.SizeWithTextOnly.Height;
+ WidthSpecification = (int)tabButtonStyle.SizeWithIcon.Width;
+ HeightSpecification = (int)tabButtonStyle.SizeWithIcon.Height;
}
- Padding = tabButtonStyle.PaddingWithTextOnly;
-
if ((tabButtonStyle.Icon != null) && (tabButtonStyle.Icon.Size != null))
{
Icon.WidthSpecification = (int)tabButtonStyle.Icon.Size.Width;
Icon.HeightSpecification = (int)tabButtonStyle.Icon.Size.Height;
}
+
+ TextLabel.PixelSize = tabButtonStyle.TextSizeWithIcon;
}
// Nothing
else
WidthSpecification = (int)tabButtonStyle.Size.Width;
HeightSpecification = (int)tabButtonStyle.Size.Height;
}
-
- Padding = tabButtonStyle.Padding;
}
}
}
}
/// <summary>
- /// Gets or sets the size of a view with text only for the width, the height, and the depth.
+ /// Gets or sets the size of a view with icon for the width, the height, and the depth.
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
- public Size SizeWithTextOnly { get; set; } = new Size();
+ public Size SizeWithIcon { get; set; } = new Size();
/// <summary>
/// Gets or sets the size of a view with icon only for the width, the height, and the depth.
public Size SizeWithIconOnly { get; set; } = new Size();
/// <summary>
- /// Gets or sets the padding with text only for use in layout.
- /// </summary>
- [EditorBrowsable(EditorBrowsableState.Never)]
- public Extents PaddingWithTextOnly { get; set; } = new Extents();
-
- /// <summary>
- /// Gets or sets the padding with icon only for use in layout.
+ /// Gets or sets the size of icon with icon only for the width, the height, and the depth.
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
- public Extents PaddingWithIconOnly { get; set; } = new Extents();
+ public Size IconSizeWithIconOnly { get; set; } = new Size();
/// <summary>
- /// Gets or sets the size of icon with icon only for the width, the height, and the depth.
+ /// Gets or sets the text font size with icon.
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
- public Size IconSizeWithIconOnly { get; set; } = new Size();
+ public float TextSizeWithIcon { get; set; }
/// <inheritdoc/>
[EditorBrowsable(EditorBrowsableState.Never)]
if (bindableObject is TabButtonStyle tabButtonStyle)
{
- SizeWithTextOnly = new Size(tabButtonStyle.SizeWithTextOnly);
+ SizeWithIcon = new Size(tabButtonStyle.SizeWithIcon);
SizeWithIconOnly = new Size(tabButtonStyle.SizeWithIconOnly);
- PaddingWithTextOnly = new Extents(tabButtonStyle.PaddingWithTextOnly);
- PaddingWithIconOnly = new Extents(tabButtonStyle.PaddingWithIconOnly);
IconSizeWithIconOnly = new Size(tabButtonStyle.IconSizeWithIconOnly);
+ TextSizeWithIcon = tabButtonStyle.TextSizeWithIcon;
}
}
}
// TabButton base style
theme.AddStyleWithoutClone("Tizen.NUI.Components.TabButton", new TabButtonStyle()
{
- Size = new Size(-1, 116),
- SizeWithTextOnly = new Size(-1, 72),
+ Size = new Size(-1, 72),
+ SizeWithIcon = new Size(-1, 116),
SizeWithIconOnly = new Size(-1, 64),
- MinimumSize = new Size(100, -1),
- Padding = new Extents(24, 24, 18, 16),
- PaddingWithTextOnly = new Extents(24, 24, 20, 20),
- PaddingWithIconOnly = new Extents(24, 24, 16, 16),
- ItemSpacing = new Size2D(0, 10),
+ MinimumSize = new Size(80, 64),
+ Padding = new Extents(24, 24, 16, 16),
+ ItemSpacing = new Size2D(10, 10),
CornerRadius = 0,
IconSizeWithIconOnly = new Size(32, 32),
+ TextSizeWithIcon = 16.0f,
BackgroundColor = new Selector<Color>()
{
Normal = new Color("#FAFAFA"),
},
Text = new TextLabelStyle()
{
- PixelSize = 28,
+ PixelSize = 24,
Size = new Size(-2, -2),
TextColor = new Selector<Color>()
{
--- /dev/null
+/*
+ * Copyright(c) 2022 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+using System;
+using Tizen.NUI;
+using Tizen.NUI.Components;
+
+namespace NUITizenGallery
+{
+ internal class TabViewWithIconOnlyTest : IExample
+ {
+ Window window;
+ Navigator navigator;
+ int pageCount = 0;
+
+ public void Activate()
+ {
+ Console.WriteLine($"@@@ this.GetType().Name={this.GetType().Name}, Activate()");
+
+ window = NUIApplication.GetDefaultWindow();
+ navigator = window.GetDefaultNavigator();
+
+ pageCount = navigator.PageCount;
+ navigator.Push(new TabViewWithIconOnlyTestPage());
+ }
+
+ public void Deactivate()
+ {
+ Console.WriteLine($"@@@ this.GetType().Name={this.GetType().Name}, Deactivate()");
+
+ for (int i = navigator.PageCount; i > pageCount; i--)
+ {
+ navigator.RemoveAt(i - 1);
+ }
+ }
+ }
+}
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" ?>
+<ContentPage x:Class="NUITizenGallery.TabViewWithIconOnlyTestPage"
+ xmlns="http://tizen.org/Tizen.NUI/2018/XAML"
+ xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
+ WidthSpecification="{Static LayoutParamPolicies.MatchParent}"
+ HeightSpecification="{Static LayoutParamPolicies.MatchParent}">
+
+ <!-- AppBar is top-side bar with navigation content, title, and action. If you not set any contents, back button is automatically added. -->
+ <ContentPage.AppBar>
+ <AppBar x:Name="appBar" Title="TabViewWithIconOnlyTestPage"/>
+ </ContentPage.AppBar>
+
+ <!-- Content is main placeholder of ContentPage. Add your content into this view. -->
+ <ContentPage.Content>
+ <TabView x:Name="tabView"
+ WidthSpecification="{Static LayoutParamPolicies.MatchParent}">
+ </TabView>
+ </ContentPage.Content>
+
+</ContentPage>
--- /dev/null
+/*
+ * Copyright(c) 2022 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+using Tizen.NUI;
+using Tizen.NUI.BaseComponents;
+using Tizen.NUI.Components;
+
+namespace NUITizenGallery
+{
+ public partial class TabViewWithIconOnlyTestPage : ContentPage
+ {
+ private int tabCount = 0;
+
+ public TabViewWithIconOnlyTestPage()
+ {
+ InitializeComponent();
+
+ tabView.SizeHeight = Window.Instance.WindowSize.Height - appBar.SizeHeight;
+
+ tabView.AddTab(CreateTabButton(), CreateView());
+ tabCount++;
+
+ tabView.AddTab(CreateTabButton(), CreateView());
+ tabCount++;
+ }
+
+ private TabButton CreateTabButton()
+ {
+ return new TabButton() { IconURL = Tizen.Applications.Application.Current.DirectoryInfo.Resource + "home.png", };
+ }
+
+ private View CreateView()
+ {
+ Color backgroundColor;
+ Color buttonBackgroundColor;
+
+ if ((tabCount + 1) % 4 == 0)
+ {
+ backgroundColor = Color.DarkGreen;
+ buttonBackgroundColor = Color.Green;
+ }
+ else if ((tabCount + 1) % 4 == 1)
+ {
+ backgroundColor = Color.DarkRed;
+ buttonBackgroundColor = Color.Red;
+ }
+ else if ((tabCount + 1) % 4 == 2)
+ {
+ backgroundColor = Color.DarkBlue;
+ buttonBackgroundColor = Color.Blue;
+ }
+ else
+ {
+ backgroundColor = Color.SaddleBrown;
+ buttonBackgroundColor = Color.Orange;
+ }
+
+ var container = new View()
+ {
+ Layout = new LinearLayout()
+ {
+ LinearOrientation = LinearLayout.Orientation.Vertical,
+ LinearAlignment = LinearLayout.Alignment.Center,
+ CellPadding = new Size2D(0, 20),
+ },
+ BackgroundColor = backgroundColor,
+ WidthSpecification = LayoutParamPolicies.MatchParent,
+ HeightSpecification = LayoutParamPolicies.MatchParent,
+ };
+
+ var buttonAddTab = new Button()
+ {
+ Text = "Add Tab",
+ BackgroundColor = buttonBackgroundColor,
+ };
+ buttonAddTab.Clicked += (object sender, ClickedEventArgs args) =>
+ {
+ if (tabCount < 4)
+ {
+ tabView.AddTab(CreateTabButton(), CreateView());
+ tabCount++;
+ }
+ };
+ container.Add(buttonAddTab);
+
+ var buttonRemoveTab = new Button()
+ {
+ Text = "Remove Tab",
+ BackgroundColor = buttonBackgroundColor,
+ };
+ buttonRemoveTab.Clicked += (object sender, ClickedEventArgs args) =>
+ {
+ if (tabCount > 1)
+ {
+ tabView.RemoveTab(tabCount - 1);
+ tabCount--;
+ }
+ };
+ container.Add(buttonRemoveTab);
+
+ return container;
+ }
+ }
+}
--- /dev/null
+/*
+ * Copyright(c) 2022 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+using System;
+using Tizen.NUI;
+using Tizen.NUI.Components;
+
+namespace NUITizenGallery
+{
+ internal class TabViewWithIconTest : IExample
+ {
+ Window window;
+ Navigator navigator;
+ int pageCount = 0;
+
+ public void Activate()
+ {
+ Console.WriteLine($"@@@ this.GetType().Name={this.GetType().Name}, Activate()");
+
+ window = NUIApplication.GetDefaultWindow();
+ navigator = window.GetDefaultNavigator();
+
+ pageCount = navigator.PageCount;
+ navigator.Push(new TabViewWithIconTestPage());
+ }
+
+ public void Deactivate()
+ {
+ Console.WriteLine($"@@@ this.GetType().Name={this.GetType().Name}, Deactivate()");
+
+ for (int i = navigator.PageCount; i > pageCount; i--)
+ {
+ navigator.RemoveAt(i - 1);
+ }
+ }
+ }
+}
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" ?>
+<ContentPage x:Class="NUITizenGallery.TabViewWithIconTestPage"
+ xmlns="http://tizen.org/Tizen.NUI/2018/XAML"
+ xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
+ WidthSpecification="{Static LayoutParamPolicies.MatchParent}"
+ HeightSpecification="{Static LayoutParamPolicies.MatchParent}">
+
+ <!-- AppBar is top-side bar with navigation content, title, and action. If you not set any contents, back button is automatically added. -->
+ <ContentPage.AppBar>
+ <AppBar x:Name="appBar" Title="TabViewWithIconTestPage"/>
+ </ContentPage.AppBar>
+
+ <!-- Content is main placeholder of ContentPage. Add your content into this view. -->
+ <ContentPage.Content>
+ <TabView x:Name="tabView"
+ WidthSpecification="{Static LayoutParamPolicies.MatchParent}">
+ </TabView>
+ </ContentPage.Content>
+
+</ContentPage>
--- /dev/null
+/*
+ * Copyright(c) 2022 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+using Tizen.NUI;
+using Tizen.NUI.BaseComponents;
+using Tizen.NUI.Components;
+
+namespace NUITizenGallery
+{
+ public partial class TabViewWithIconTestPage : ContentPage
+ {
+ private int tabCount = 0;
+
+ public TabViewWithIconTestPage()
+ {
+ InitializeComponent();
+
+ tabView.SizeHeight = Window.Instance.WindowSize.Height - appBar.SizeHeight;
+
+ tabView.AddTab(CreateTabButton(), CreateView());
+ tabCount++;
+
+ tabView.AddTab(CreateTabButton(), CreateView());
+ tabCount++;
+ }
+
+ private TabButton CreateTabButton()
+ {
+ return new TabButton()
+ {
+ Text = "Tab" + (tabCount + 1),
+ IconURL = Tizen.Applications.Application.Current.DirectoryInfo.Resource + "home.png",
+ };
+ }
+
+ private View CreateView()
+ {
+ Color backgroundColor;
+ Color buttonBackgroundColor;
+
+ if ((tabCount + 1) % 4 == 0)
+ {
+ backgroundColor = Color.DarkGreen;
+ buttonBackgroundColor = Color.Green;
+ }
+ else if ((tabCount + 1) % 4 == 1)
+ {
+ backgroundColor = Color.DarkRed;
+ buttonBackgroundColor = Color.Red;
+ }
+ else if ((tabCount + 1) % 4 == 2)
+ {
+ backgroundColor = Color.DarkBlue;
+ buttonBackgroundColor = Color.Blue;
+ }
+ else
+ {
+ backgroundColor = Color.SaddleBrown;
+ buttonBackgroundColor = Color.Orange;
+ }
+
+ var container = new View()
+ {
+ Layout = new LinearLayout()
+ {
+ LinearOrientation = LinearLayout.Orientation.Vertical,
+ LinearAlignment = LinearLayout.Alignment.Center,
+ CellPadding = new Size2D(0, 20),
+ },
+ BackgroundColor = backgroundColor,
+ WidthSpecification = LayoutParamPolicies.MatchParent,
+ HeightSpecification = LayoutParamPolicies.MatchParent,
+ };
+
+ var buttonAddTab = new Button()
+ {
+ Text = "Add Tab",
+ BackgroundColor = buttonBackgroundColor,
+ };
+ buttonAddTab.Clicked += (object sender, ClickedEventArgs args) =>
+ {
+ if (tabCount < 4)
+ {
+ tabView.AddTab(CreateTabButton(), CreateView());
+ tabCount++;
+ }
+ };
+ container.Add(buttonAddTab);
+
+ var buttonRemoveTab = new Button()
+ {
+ Text = "Remove Tab",
+ BackgroundColor = buttonBackgroundColor,
+ };
+ buttonRemoveTab.Clicked += (object sender, ClickedEventArgs args) =>
+ {
+ if (tabCount > 1)
+ {
+ tabView.RemoveTab(tabCount - 1);
+ tabCount--;
+ }
+ };
+ container.Add(buttonRemoveTab);
+
+ return container;
+ }
+ }
+}
--- /dev/null
+/*
+ * Copyright(c) 2022 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+using System;
+using System.ComponentModel;
+using Tizen.NUI;
+using Tizen.NUI.BaseComponents;
+using Tizen.NUI.Components;
+
+namespace Tizen.NUI.StyleGuide
+{
+ // IExample inehrited class will be automatically added in the main examples list.
+ internal class TabViewWithIconExample : ContentPage, IExample
+ {
+ private const int maxTabCount = 4;
+ private const int colorOne = 0, colorTwo = 1, colorThree = 2;
+ private int tabCount = 0;
+ private TabView tabView;
+
+ public void Activate()
+ {
+ }
+ public void Deactivate()
+ {
+ }
+
+ /// Modify this method for adding other examples.
+ public TabViewWithIconExample() : base()
+ {
+ WidthSpecification = LayoutParamPolicies.MatchParent;
+ HeightSpecification = LayoutParamPolicies.MatchParent;
+
+ // Navigator bar title is added here.
+ AppBar = new AppBar()
+ {
+ Title = "TabView Default Style",
+ };
+
+ tabView = new TabView()
+ {
+ WidthSpecification = LayoutParamPolicies.MatchParent,
+ };
+ Content = tabView;
+
+ tabView.AddTab(CreateTabButton(), CreateView());
+ tabCount++;
+
+ tabView.AddTab(CreateTabButton(), CreateView());
+ tabCount++;
+ }
+
+ private TabButton CreateTabButton()
+ {
+ return new TabButton()
+ {
+ Text = "Tab" + (tabCount + 1),
+ IconURL = Tizen.Applications.Application.Current.DirectoryInfo.Resource + "home.png",
+ };
+ }
+
+ private View CreateView()
+ {
+ Color backgroundColor;
+ Color buttonBackgroundColor;
+
+ if ((tabCount + 1) % maxTabCount == colorOne)
+ {
+ backgroundColor = Color.DarkGreen;
+ buttonBackgroundColor = Color.Green;
+ }
+ else if ((tabCount + 1) % maxTabCount == colorTwo)
+ {
+ backgroundColor = Color.DarkRed;
+ buttonBackgroundColor = Color.Red;
+ }
+ else if ((tabCount + 1) % maxTabCount == colorThree)
+ {
+ backgroundColor = Color.DarkBlue;
+ buttonBackgroundColor = Color.Blue;
+ }
+ else
+ {
+ backgroundColor = Color.SaddleBrown;
+ buttonBackgroundColor = Color.Orange;
+ }
+
+ var container = new View()
+ {
+ Layout = new LinearLayout()
+ {
+ LinearOrientation = LinearLayout.Orientation.Vertical,
+ HorizontalAlignment = HorizontalAlignment.Center,
+ VerticalAlignment = VerticalAlignment.Center,
+ CellPadding = new Size2D(0, 20),
+ },
+ BackgroundColor = backgroundColor,
+ WidthSpecification = LayoutParamPolicies.MatchParent,
+ HeightSpecification = LayoutParamPolicies.MatchParent,
+ };
+
+ var buttonAddTab = new Button()
+ {
+ Text = "Add Tab",
+ BackgroundColor = buttonBackgroundColor,
+ };
+ buttonAddTab.Clicked += (object sender, ClickedEventArgs args) =>
+ {
+ if (tabCount < maxTabCount)
+ {
+ tabView.AddTab(CreateTabButton(), CreateView());
+ tabCount++;
+ }
+ };
+ container.Add(buttonAddTab);
+
+ var buttonRemoveTab = new Button()
+ {
+ Text = "Remove Tab",
+ BackgroundColor = buttonBackgroundColor,
+ };
+ buttonRemoveTab.Clicked += (object sender, ClickedEventArgs args) =>
+ {
+ if (tabCount > 1)
+ {
+ tabView.RemoveTab(tabCount - 1);
+ tabCount--;
+ }
+ };
+ container.Add(buttonRemoveTab);
+
+ return container;
+ }
+
+ }
+}
--- /dev/null
+/*
+ * Copyright(c) 2022 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+using System;
+using System.ComponentModel;
+using Tizen.NUI;
+using Tizen.NUI.BaseComponents;
+using Tizen.NUI.Components;
+
+namespace Tizen.NUI.StyleGuide
+{
+ // IExample inehrited class will be automatically added in the main examples list.
+ internal class TabViewWithIconOnlyExample : ContentPage, IExample
+ {
+ private const int maxTabCount = 4;
+ private const int colorOne = 0, colorTwo = 1, colorThree = 2;
+ private int tabCount = 0;
+ private TabView tabView;
+
+ public void Activate()
+ {
+ }
+ public void Deactivate()
+ {
+ }
+
+ /// Modify this method for adding other examples.
+ public TabViewWithIconOnlyExample() : base()
+ {
+ WidthSpecification = LayoutParamPolicies.MatchParent;
+ HeightSpecification = LayoutParamPolicies.MatchParent;
+
+ // Navigator bar title is added here.
+ AppBar = new AppBar()
+ {
+ Title = "TabView Default Style",
+ };
+
+ tabView = new TabView()
+ {
+ WidthSpecification = LayoutParamPolicies.MatchParent,
+ };
+ Content = tabView;
+
+ tabView.AddTab(CreateTabButton(), CreateView());
+ tabCount++;
+
+ tabView.AddTab(CreateTabButton(), CreateView());
+ tabCount++;
+ }
+
+ private TabButton CreateTabButton()
+ {
+ return new TabButton()
+ {
+ IconURL = Tizen.Applications.Application.Current.DirectoryInfo.Resource + "home.png",
+ };
+ }
+
+ private View CreateView()
+ {
+ Color backgroundColor;
+ Color buttonBackgroundColor;
+
+ if ((tabCount + 1) % maxTabCount == colorOne)
+ {
+ backgroundColor = Color.DarkGreen;
+ buttonBackgroundColor = Color.Green;
+ }
+ else if ((tabCount + 1) % maxTabCount == colorTwo)
+ {
+ backgroundColor = Color.DarkRed;
+ buttonBackgroundColor = Color.Red;
+ }
+ else if ((tabCount + 1) % maxTabCount == colorThree)
+ {
+ backgroundColor = Color.DarkBlue;
+ buttonBackgroundColor = Color.Blue;
+ }
+ else
+ {
+ backgroundColor = Color.SaddleBrown;
+ buttonBackgroundColor = Color.Orange;
+ }
+
+ var container = new View()
+ {
+ Layout = new LinearLayout()
+ {
+ LinearOrientation = LinearLayout.Orientation.Vertical,
+ HorizontalAlignment = HorizontalAlignment.Center,
+ VerticalAlignment = VerticalAlignment.Center,
+ CellPadding = new Size2D(0, 20),
+ },
+ BackgroundColor = backgroundColor,
+ WidthSpecification = LayoutParamPolicies.MatchParent,
+ HeightSpecification = LayoutParamPolicies.MatchParent,
+ };
+
+ var buttonAddTab = new Button()
+ {
+ Text = "Add Tab",
+ BackgroundColor = buttonBackgroundColor,
+ };
+ buttonAddTab.Clicked += (object sender, ClickedEventArgs args) =>
+ {
+ if (tabCount < maxTabCount)
+ {
+ tabView.AddTab(CreateTabButton(), CreateView());
+ tabCount++;
+ }
+ };
+ container.Add(buttonAddTab);
+
+ var buttonRemoveTab = new Button()
+ {
+ Text = "Remove Tab",
+ BackgroundColor = buttonBackgroundColor,
+ };
+ buttonRemoveTab.Clicked += (object sender, ClickedEventArgs args) =>
+ {
+ if (tabCount > 1)
+ {
+ tabView.RemoveTab(tabCount - 1);
+ tabCount--;
+ }
+ };
+ container.Add(buttonRemoveTab);
+
+ return container;
+ }
+
+ }
+}