我有一个TabbedPage,有3个孩子。
public partial class FactoryDetailsTabs : TabbedPage
{
public FactoryDetailsTabs()
{
InitializeComponent();
Children.Add(new FactoryDetailsTabs_DashboardTab());
Children.Add(new FactoryDetailsTabs_AnalysisTab());
Children.Add(new FactoryDetailsTabs_SettingsTab());
}
}
第3个标签包含设置页面。使用以下代码
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="LogicalSugarDemoApp.Pages.FactoryDetailsTabs_SettingsTab"
xmlns:controls="clr-namespace:LogicalSugarDemoApp.NativeModels"
Title="Settings" Icon="settings">
<RelativeLayout>
<Frame x:Name="LanguageFrame" BackgroundColor="Pink">
<RelativeLayout
RelativeLayout.XConstraint=
"{ConstraintExpression Type=RelativeToParent,
Property=Width,
Factor=0.20}"
RelativeLayout.YConstraint=
"{ConstraintExpression Type=RelativeToParent,
Property=Height,
Factor=10.00}"
RelativeLayout.WidthConstraint=
"{ConstraintExpression Type=RelativeToParent,
Property=Width,
Factor=0.40}"
RelativeLayout.HeightConstraint=
"{ConstraintExpression Type=RelativeToParent,
Property=Height,
Factor=0.05}">
<Label x:Name="SelectLangLabel"
Text="Select Language"
TextColor="Black"
BackgroundColor="Teal"
FontFamily="Arial"
FontSize="30"
FontAttributes="Bold"
RelativeLayout.XConstraint=
"{ConstraintExpression Type=RelativeToParent,
Property=Width,
Factor=0.02}"
RelativeLayout.YConstraint=
"{ConstraintExpression Type=RelativeToParent,
Property=Height,
Factor=0.05}"
RelativeLayout.WidthConstraint=
"{ConstraintExpression Type=RelativeToParent,
Property=Width,
Factor=0.70}"
RelativeLayout.HeightConstraint=
"{ConstraintExpression Type=RelativeToParent,
Property=Height,
Factor=0.10}"/>
<Picker x:Name="LanguagePicker"
Title="English"
BackgroundColor="#e9e9e9"
RelativeLayout.XConstraint=
"{ConstraintExpression Type=RelativeToParent,
Property=Width,
Factor=0.76}"
RelativeLayout.YConstraint=
"{ConstraintExpression Type=RelativeToParent,
Property=Height,
Factor=0.05}"
RelativeLayout.WidthConstraint=
"{ConstraintExpression Type=RelativeToParent,
Property=Width,
Factor=0.23}"
RelativeLayout.HeightConstraint=
"{ConstraintExpression Type=RelativeToParent,
Property=Height,
Factor=0.10}"/>
</RelativeLayout>
</Frame>
</RelativeLayout>
<controls:AdView HorizontalOptions="Center" VerticalOptions="EndAndExpand"/>
</ContentPage>
我没有在标签页中的第3页上获得任何输出。但是当我在TabbedPage之外的内容页面中执行此代码时,该代码可以正常工作。请帮忙。我在TabbedPage中需要它
答案 0 :(得分:0)
我认为你应该将RelativeLayout添加到ContentPage.Content。像
这样的东西<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="LogicalSugarDemoApp.Pages.FactoryDetailsTabs_SettingsTab"
xmlns:controls="clr-namespace:LogicalSugarDemoApp.NativeModels"
Title="Settings" Icon="settings">
<ContentPage.Content>
<RelativeLayout>
<Frame x:Name="LanguageFrame" BackgroundColor="Pink">
<RelativeLayout
RelativeLayout.XConstraint=
"{ConstraintExpression Type=RelativeToParent,
Property=Width,
Factor=0.20}"
RelativeLayout.YConstraint=
"{ConstraintExpression Type=RelativeToParent,
Property=Height,
Factor=10.00}"
RelativeLayout.WidthConstraint=
"{ConstraintExpression Type=RelativeToParent,
Property=Width,
Factor=0.40}"
RelativeLayout.HeightConstraint=
"{ConstraintExpression Type=RelativeToParent,
Property=Height,
Factor=0.05}">
<Label x:Name="SelectLangLabel"
Text="Select Language"
TextColor="Black"
BackgroundColor="Teal"
FontFamily="Arial"
FontSize="30"
FontAttributes="Bold"
RelativeLayout.XConstraint=
"{ConstraintExpression Type=RelativeToParent,
Property=Width,
Factor=0.02}"
RelativeLayout.YConstraint=
"{ConstraintExpression Type=RelativeToParent,
Property=Height,
Factor=0.05}"
RelativeLayout.WidthConstraint=
"{ConstraintExpression Type=RelativeToParent,
Property=Width,
Factor=0.70}"
RelativeLayout.HeightConstraint=
"{ConstraintExpression Type=RelativeToParent,
Property=Height,
Factor=0.10}"/>
<Picker x:Name="LanguagePicker"
Title="English"
BackgroundColor="#e9e9e9"
RelativeLayout.XConstraint=
"{ConstraintExpression Type=RelativeToParent,
Property=Width,
Factor=0.76}"
RelativeLayout.YConstraint=
"{ConstraintExpression Type=RelativeToParent,
Property=Height,
Factor=0.05}"
RelativeLayout.WidthConstraint=
"{ConstraintExpression Type=RelativeToParent,
Property=Width,
Factor=0.23}"
RelativeLayout.HeightConstraint=
"{ConstraintExpression Type=RelativeToParent,
Property=Height,
Factor=0.10}"/>
</RelativeLayout>
</Frame>
</RelativeLayout>
<controls:AdView HorizontalOptions="Center" VerticalOptions="EndAndExpand"/>
</ContentPage.Content>
</ContentPage>
但我不知道它是否能解决问题