【问题标题】:Creating Bottom Navigation Bar for Android and iOS using Xamarin Forms使用 Xamarin Forms 为 Android 和 iOS 创建底部导航栏
【发布时间】:2019-09-06 22:55:00
【问题描述】:

是否可以在不使用自定义渲染器的情况下使用 Xamarin 表单为 Android 和 iOS 创建底部导航栏。

我听说最新的 Xamarin Forms 支持底部导航栏功能,但遗憾的是我找不到合适的文档。

需要一些帮助/指南来实施相同的操作。

【问题讨论】:

标签: xamarin.forms xamarin.android


【解决方案1】:

我正在分享我的应用程序代码,希望对您有所帮助。

XML 页面:

<?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="iSAS.Mobile.Views.Student.SettingsPage"
         Title="Profile" 
         xmlns:android="clr-namespace:Xamarin.Forms.PlatformConfiguration.AndroidSpecific;assembly=Xamarin.Forms.Core"
         BarBackgroundColor="White"
         BarTextColor="#2196F3" 
         android:TabbedPage.ToolbarPlacement="Bottom"
         android:TabbedPage.BarItemColor="#66FFFFFF"
         android:TabbedPage.BarSelectedItemColor="#2196F3" >
 </TabbedPage>

CS 页面:

[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class SettingsPage : TabbedPage
{
    public SettingsPage()
    {
        InitializeComponent();
        Children.Add(new ProfilePage());
        Children.Add(new ChangePassword());
        Children[0].Icon = "profile.png";
        Children[1].Icon = "settings.png";

        CurrentPage = Children[1];
    }

    public SettingsPage(bool DefaultChangePswdPage = true)
    {
        InitializeComponent();
        Children.Add(new ProfilePage());
        Children.Add(new ChangePassword());
        Children[0].Icon = "profile.png";

        Children[1].Icon = "settings.png";
        if (DefaultChangePswdPage)
            CurrentPage = Children[1];
    }
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-12-03
    • 1970-01-01
    • 2016-12-13
    • 1970-01-01
    • 1970-01-01
    • 2021-10-07
    • 2017-07-18
    • 2017-05-07
    相关资源
    最近更新 更多