我们可以在 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

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...