微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

我们可以在 xamarin.forms 中制作可滚动的底部标签页吗

如何解决我们可以在 xamarin.forms 中制作可滚动的底部标签页吗

我在底部有四个标签,问题是,最后一个标签标题不完全可见,我想通过将标签模式设置为可滚动它会设置,即使我将 tabmode 设置为可滚动问题存在。

有人可以帮助我实现这一目标吗?

enter image description here

enter image description here

这是我的 xaml 代码

    <?xml version="1.0" encoding="utf-8" ?>
<TabbedPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:android="clr-namespace:Xamarin.Forms.PlatformConfiguration.AndroidSpecific;assembly=Xamarin.Forms.Core"
             android:TabbedPage.BarItemColor="LightGray"
             android:TabbedPage.BarSelectedItemColor="White"
             android:TabbedPage.IsSmoothScrollEnabled="True"         
             x:Class="MyApp.Views.DashBoardTabbedPage" BarBackgroundColor="#00abbf">
  <!--Pages can be added as references or inline-->
</TabbedPage>

xaml.cs 构造函数

var  _dashboardview = new DashBoard();
            _dashboardview.Title = "1";
            _dashboardview.IconImageSource = "refresh";
            this.Children.Add(_dashboardview); //Added other 3 tabs in this way
            On<Android>().SetToolbarPlacement(ToolbarPlacement.Bottom);

解决方法

如果您有兴趣,可以将应用程序基本页面更改为更新的 Shell type,然后使用嵌套 TabbarTab 的组合来定义底部和上部选项卡。尽管默认行为是超过 5 个底部选项卡,其余选项卡将隐藏在一个分组列表中,该列表可通过右侧边缘的 3 点“更多”菜单访问。

enter image description here

但是,如果您更喜欢可滚动的选项卡,我建议您使用以下任一软件包,因为它不是内置在 Xamarin.Forms 中的:

  • Xamarin.CommunityToolkitTabView 为您的标签提供了很好的控制和自定义选项,包括内置的滚动,文档很快就会与第一个稳定版本相同(计划在本周发布,但已在预发行版中提供),但同时您可以查看 TabView。请注意,此软件包不仅为标签页提供了大量多样且有用的功能。

enter image description here

  • 您可以查看的另一个不错的包是带有 TabType.ScrollableSharpnado.Tabs

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。