使用FreshMVVM的FreshTabbedNavigationContainer
所有标签都希望同时显示并截断:
我希望它们是全宽和可滚动的,就像使用常规TabbedPage
:
我实际上并没有这么多标签。这只是一个展示我的意思的例子。
答案 0 :(得分:1)
您需要使用CustomRednerer
例如:
在Droid项目中:
[assembly: ExportRenderer(typeof(ScrollableTabbedPage), typeof(ScrollableTabbedPageRenderer))]
namespace ScrollableFreshTabbed.Droid
{
class ScrollableTabbedPageRenderer : TabbedPageRenderer
{
public ScrollableTabbedPageRenderer(Context context) : base(context)
{
}
public override void OnViewAdded(Android.Views.View child)
{
base.OnViewAdded(child);
var tabLayout = child as TabLayout;
if (tabLayout != null)
{
tabLayout.TabMode = TabLayout.ModeScrollable;
}
}
}
}
在便携式项目中:
public class ScrollableTabbedPage : FreshTabbedNavigationContainer
{
public ScrollableTabbedPage ()
{
}
}
App.xaml.cs:
public App ()
{
InitializeComponent();
var tabbedNavigation = new ScrollableTabbedPage();
tabbedNavigation.AddTab<QuotePageModel>("Contacts", null);
tabbedNavigation.AddTab<QuotePageModel>("Contacts", null);
tabbedNavigation.AddTab<QuotePageModel>("Contacts", null);
tabbedNavigation.AddTab<QuotePageModel>("Contacts", null);
tabbedNavigation.AddTab<QuotePageModel>("Contacts", null);
tabbedNavigation.AddTab<QuotePageModel>("Contacts", null);
tabbedNavigation.AddTab<QuotePageModel>("Contacts", null);
tabbedNavigation.AddTab<QuotePageModel>("Contacts", null);
tabbedNavigation.AddTab<QuotePageModel>("Contacts", null);
tabbedNavigation.AddTab<QuotePageModel>("Contacts", null);
tabbedNavigation.AddTab<QuotePageModel>("Contacts", null);
tabbedNavigation.AddTab<QuotePageModel>("Contacts", null);
tabbedNavigation.AddTab<QuotePageModel>("Contacts", null);
tabbedNavigation.AddTab<QuotePageModel>("Contacts", null);
tabbedNavigation.AddTab<QuotePageModel>("Contacts", null);
tabbedNavigation.AddTab<QuotePageModel>("Contacts", null);
MainPage = tabbedNavigation;
}