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

标签 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>

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

最佳答案

这是设计使然。 Forms 旨在通过使用各自的 UI 标准在每个平台上提供 native 体验。 Android 的默认配色方案与 iOS 不同。 iOS 默认按钮看起来与 Android 不同。

如果您愿意,您可以覆盖默认字体、大小、颜色等,以提供更一致的 UI。 Xamarin还推出了Themes用于帮助您在平台之间提供一致的 UI 的表单。

关于XAMARIN 表单 - 为什么相同的表单在 iOS 和 Android 上看起来不同,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37402410/

相关文章:

ios - UIScreenEdgePanGestureRecognizer 对 subview 没有反应

ios - 我如何将内容置于 View Controller 的中心,以便无论 xamarin Storyboard 中使用什么设备尺寸,它始终居中?

c# - 在 Xamarin Forms PCL 中从 Javascript 调用 C# 函数

ios - akavache 不在 ios 模拟器/设备中缓存

Xamarin Forms ContextAction MenuItem 文本颜色

xamarin.ios - iOS8:backgroundSessionConfiguration 已弃用

ios - 如何在 xamarin 中创建这样的布局?

Xamarin 中的 Android Assist API?

xamarin.forms - 您真的应该将图像的三个副本放入 Xamarin.Forms 项目中吗?

c# - 创建我们自己的内容页面时出现 Xaml 错误