模拟器显示与 Xamarin.Forms 预览器不同的输出

Emulator showing different output than Xamarin.Forms Previewer

我有 Master LayoutMasterDetailPage。在 Xamarin.Forms 预览器 window 中按预期显示输出。但是当我在 Android 模拟器上执行它时,输出显示几乎没有什么不同。我该如何解决这个问题?我的代码是

<MasterDetailPage.Master>
    <ContentPage Title="MasterP" >
        <StackLayout BackgroundColor="#01796F">
        <StackLayout Margin="25,10,25,0" Padding="0,30,0,0">
            <Image  BackgroundColor="Accent" Aspect="AspectFill" Source="Enrich.png"></Image>
        </StackLayout>
        <StackLayout  Margin="20,10,20,0" >
            <Button  Margin="20,5,20,0"   HorizontalOptions="FillAndExpand" Text="Menu 1"></Button>
            <Button  Margin="20,0,20,0"   HorizontalOptions="FillAndExpand" Text="Menu 1"></Button>
            <Button  Margin="20,0,20,0"   HorizontalOptions="FillAndExpand" Text="Menu 1"></Button>
        </StackLayout>
        </StackLayout>
    </ContentPage>
</MasterDetailPage.Master>

输出:

预览器的屏幕尺寸不一定与您正在模拟的 phone 相同。预览器和 emulator/physical 设备之间会有一些差异。

您设置的纵横比 属性 将归档整个视图,剪掉其他边缘。查看 Microsoft 文档中的 the Aspect Enum documentation。听起来你想要的方面是 AspectFit.