小编n.l*_*ell的帖子

xamarin 应用程序启动缓慢

我们正在 PCL 上开发跨平台应用程序,但目前我们仅使用 android 设备进行测试。
我们担心的是,启动应用程序需要大约 6 到 8 秒(取决于我们测试的设备),这非常慢。
放置几个断点后,我们看到时间消耗相当均匀。
我们确实注意到这个特定部分花费了更长的时间:

  • 在 MainActivity 上到达 onCreate() 之前 1 秒(有一个闪屏,在它之前只有一个图像和一个背景颜色)
  • 1 秒 base.OnCreate(bundle);
  • 1 秒 global::Xamarin.Forms.Forms.Init(this, bundle);
  • 1.5 秒Page mainPage = new LogScreen();(创建主页面,然后将其设置为主导航页面)。

cross-platform app-startup xamarin.android xamarin xamarin.forms

8
推荐指数
3
解决办法
9436
查看次数

如何从跨平台 xamarin XAML 上的资产目录加载图像?

这似乎是一件非常容易的事情,理论上它看起来非常简单:

  1. 创建资产目录
  2. 添加图像集并将其命名为“imageName”(不带 .png)
  3. 添加图像
  4. 完毕

或者至少这是我在任何地方读到的,但我仍然无法让它工作。

我的 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)

xaml cross-platform xamarin.ios asset-catalog xamarin.forms

5
推荐指数
1
解决办法
2880
查看次数