TabbedPage 中的两个选项卡没有占据全宽,而是将它们的文本宽度限制在选项卡的左上角
Two tabs in TabbedPage are not taking full width instead they are limited to their text width to the left corner of the tab
我必须在 TabbedPage 中填充两个选项卡,使两个选项卡的宽度应相等。
这是我在 TabbedPage 中的代码:
protected override void OnAppearing()
{
base.OnAppearing();
EquipmentGeneralInfoTab = new EquipmentGeneralInfoTab() { Title = "General" };
EquipmentMaintenanceTab = new EquipmentMaintenanceTab() { Title = "Maintenance" };
this.Children.Add(EquipmentGeneralInfoTab);
this.Children.Add(EquipmentMaintenanceTab);
}
Xaml代码:
<TabbedPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="TCRMobile.Pages.EquipmentInfoTabbedPage"
Title="Equipment">
Tabbar.xaml:
<android.support.design.widget.TabLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/sliding_tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
android:theme="@style/Your.Theme"
app:tabIndicatorColor="@color/tcr_green"
app:tabSelectedTextColor="@color/tcr_green"
app:tabTextColor="@color/black"
app:tabGravity="fill"
app:tabMaxWidth="0dp"
app:tabTextAppearance="@style/tab_text"
app:tabMode="scrollable" />
如何完成我的要求?
尝试更改Tabbar.xaml
中的以下代码
app:tabMode="scrollable"
到
app:tabMode="fixed"
我必须在 TabbedPage 中填充两个选项卡,使两个选项卡的宽度应相等。
这是我在 TabbedPage 中的代码:
protected override void OnAppearing()
{
base.OnAppearing();
EquipmentGeneralInfoTab = new EquipmentGeneralInfoTab() { Title = "General" };
EquipmentMaintenanceTab = new EquipmentMaintenanceTab() { Title = "Maintenance" };
this.Children.Add(EquipmentGeneralInfoTab);
this.Children.Add(EquipmentMaintenanceTab);
}
Xaml代码:
<TabbedPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="TCRMobile.Pages.EquipmentInfoTabbedPage"
Title="Equipment">
Tabbar.xaml:
<android.support.design.widget.TabLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/sliding_tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
android:theme="@style/Your.Theme"
app:tabIndicatorColor="@color/tcr_green"
app:tabSelectedTextColor="@color/tcr_green"
app:tabTextColor="@color/black"
app:tabGravity="fill"
app:tabMaxWidth="0dp"
app:tabTextAppearance="@style/tab_text"
app:tabMode="scrollable" />
如何完成我的要求?
尝试更改Tabbar.xaml
中的以下代码
app:tabMode="scrollable"
到
app:tabMode="fixed"