首页 文章

我的Xamarin.forms图片没有加载,你能帮帮我吗?

提问于
浏览
0

我试着创建一个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());
        }
    }
}

预先感谢

louga31

1 回答

  • 0

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

相关问题