我们正在 PCL 上开发跨平台应用程序,但目前我们仅使用 android 设备进行测试。
我们担心的是,启动应用程序需要大约 6 到 8 秒(取决于我们测试的设备),这非常慢。
放置几个断点后,我们看到时间消耗相当均匀。
我们确实注意到这个特定部分花费了更长的时间:
base.OnCreate(bundle);
global::Xamarin.Forms.Forms.Init(this, bundle);
Page mainPage = new LogScreen();
(创建主页面,然后将其设置为主导航页面)。cross-platform app-startup xamarin.android xamarin xamarin.forms
这似乎是一件非常容易的事情,理论上它看起来非常简单:
或者至少这是我在任何地方读到的,但我仍然无法让它工作。
我的 XAML 看起来像这样:
<?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:local="clr-namespace:CrossBaiscs"
x:Class="CrossBaiscs.MainPage">
<ContentPage.Content>
<StackLayout BackgroundColor="Orange">
<Label Text="Welcome to Xamarin.Forms!"
TextColor="White"
VerticalOptions="CenterAndExpand"
HorizontalOptions="CenterAndExpand" />
<Image VerticalOptions="CenterAndExpand"
HorizontalOptions="Center"
Source="logo1.png"/>
</StackLayout>
</ContentPage.Content>
</ContentPage>
Run Code Online (Sandbox Code Playgroud)
我在资产目录上添加了图像:
我正在 Iphone 6 上使用 Xamarin Live Player 进行测试,但在标签下看不到任何图像。
所以......我错过了什么?
编辑
它适用于这个人:Is it possible to use Image Set in a Xamarin Forms
但不适合我,我确实尝试删除 .png 扩展名并像这样保留 xaml:
<?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:local="clr-namespace:CrossBaiscs"
x:Class="CrossBaiscs.MainPage">
<ContentPage.Content>
<StackLayout BackgroundColor="Orange">
<Label Text="Welcome to Xamarin.Forms!" …
Run Code Online (Sandbox Code Playgroud)