将图像文件与 Tizen.NET 可穿戴应用程序一起使用使用 Visual Studio

问题描述

我是 Tizen.NET 的初学者,我想在我的可穿戴应用程序中使用在我的开发机器上创建的图像。我在 Visual Studio 中创建了一个示例 TizenWearable 应用。

我在 shared/res 中保存了一个 circle-cropped.PNG 图像文件

enter image description here

添加了以下代码来测试使用图像作为背景图像:

    // The root page of your application
    MainPage = new ContentPage
    {
        BackgroundImageSource = "circle-cropped.png",Content = new StackLayout
        {
            VerticalOptions = Layoutoptions.Center,Children = {
                new Label {
                    HorizontalTextAlignment = TextAlignment.Center,Text = "Welcome to Tizen!"
                },button,label,button2
            }
        }
    };

然而,当我运行模拟器进行检查时,我的其他标签和按钮呈现良好,但背景为黑色,没有图像。

enter image description here

如果我运行模拟器 shell,我可以看到我的图像似乎包含在文件系统中:

sh-3.2$ ls
TizenWearableApp1.png  circle-cropped.png
sh-3.2$

我哪里出错了?

解决方法

您应该将资源放在 res 文件夹中。

shared/res 文件夹用于与其他应用程序共享资源,不应将私有应用程序资源放在那里。

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...