XAMARIN表单 - 为什么相同的表单在iOS和Android上看起来不同

Zby*_*ski 2 xamarin xamarin.forms

我决定尝试Xamarin Forms,因为我认为我可以为所有平台或至少Android和iOS制作一个设计.但是一个简单的形式如:

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:app91="clr-namespace:App9;assembly=MasterDetail.Android"
             x:Class="MasterDetail.CompetitorsListPage"
             >
    <StackLayout>
      <Label Text="{Binding CurrentEvent.Name}"></Label>
      <StackLayout Orientation="Horizontal">
        <Button Text="By Place" Clicked="Button_OnClickedByPlace"></Button>
        <Button Text="By Number" Clicked="Button_OnClickedByNumber"></Button>
        <Button Text="By Rating" Clicked="Button_OnClickedByRating"></Button>
        <Button Text="Change Event" Clicked="Button_OnClickedChangeEvent"></Button>
      </StackLayout>
        <ScrollView>
            <ListView x:Name="couples" ItemSelected="Comps_OnItemSelected" ItemTapped="Couples_OnItemTapped">
                <ListView.ItemTemplate>
                    <DataTemplate>
                        <ViewCell>
                            <ViewCell.View>
                                <StackLayout Orientation="Horizontal">
                                    <Label Text="{Binding Round}"></Label>
                                    <Label Text="{Binding Pos, StringFormat='({0}).'}"></Label>
                                  <Label Text="{Binding Name}"></Label>
                                  <Label Text="{Binding StartingNumber}" ></Label>
                                  <Label Text="{Binding OldRating, StringFormat=' [{0}]'}"></Label>
                                  <!--<Label Text="{Binding NewRating, StringFormat=' {0} ]'}"></Label>-->
                                </StackLayout>
                            </ViewCell.View>
                        </ViewCell>
                    </DataTemplate>
                </ListView.ItemTemplate>
            </ListView>
        </ScrollView>
    </StackLayout>
</ContentPage>
Run Code Online (Sandbox Code Playgroud)

在Android和iOS上看起来完全不同.我不介意颜色,但字体大小?我没有在代码或xaml中的任何位置设置字体.知道我做错了什么吗?这是一张显示两个版本的图片: 在此输入图像描述

Jas*_*son 6

这是设计的.表单旨在通过使用各自的UI标准在每个平台上提供本机体验.Android具有与iOS不同的默认配色方案.iOS默认按钮与Android不同.

如果您愿意,可以覆盖默认字体,大小,颜色等,以提供更一致的UI.Xamarin还引入了主题表单,可帮助您在平台之间提供一致的UI.