【问题标题】:My Xamarin.forms images didn't load, can you help me?我的 Xamarin.forms 图像未加载,您能帮帮我吗?
【发布时间】:2018-12-08 19:31:35
【问题描述】:

我正在尝试制作一个跨平台的应用程序,并且我正在尝试创建一个 SplashScreen。 我已将所有图像添加到 Ressources 文件夹并将它们放入嵌入式资源中,但我没有看到它们。 Ressource folder

The result I got

<?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:DVHub"
         x:Class="DVHub.MainPage">
    <ContentPage.Content>
        <StackLayout VerticalOptions="FillAndExpand"
                HorizontalOptions="FillAndExpand"
                Orientation="Vertical"
                BackgroundColor="White">
            <Image x:Name="logo" 
                   Scale="1.4"
                   TranslationX="-120"
                   TranslationY="35"/>
            <Image x:Name="splashScreen"  
                   Scale="1.2"
                   TranslationY="120"/>
        </StackLayout>
</ContentPage.Content>

表单类:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xamarin.Forms;
using System.Timers;

namespace DVHub
{
    public partial class MainPage : ContentPage
    {
        public MainPage()
        {
            InitializeComponent();
            NavigationPage.SetHasNavigationBar(this, false);
            logo.Source = ImageSource.FromFile("logo.png");
            splashScreen.Source = ImageSource.FromFile("splashScreen.png");
            Timer timer = new Timer
            {
                Interval = 3000,
                AutoReset = false
            };
            timer.Elapsed += Timer_Elapsed;
            timer.Start();
        }
        private void Timer_Elapsed(object sender, ElapsedEventArgs e)
        {
            // await Navigation.PushAsync(new Infos(), true);
            Application.Current.MainPage = new NavigationPage(new Infos());
        }
    }
}

提前致谢

卢加31

【问题讨论】:

    标签: c# xamarin xamarin.forms xamarin.ios xamarin.android


    【解决方案1】:

    我不确定 ios,但对于 android,您应该将 Build Action 设置为 AndroidResource。希望,这会有所帮助。

    【讨论】:

    • 成功了,谢谢,我刚刚学习了一个糟糕的教程。
    猜你喜欢
    • 2022-08-10
    • 2015-07-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-04-17
    • 2019-05-29
    • 1970-01-01
    • 2019-01-09
    相关资源
    最近更新 更多