【发布时间】:2019-04-08 15:41:56
【问题描述】:
我想在我的 Xamarin Forms Android 应用程序中使用图片作为背景。该图像存储在可绘制文件夹中。当我在智能手机上调试应用程序时,图像不显示。下面是代码。谢谢
<?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:XamarinTest"
x:Class="XamarinTest.MainPage"
BackgroundImage = "BGImage.jpeg">
<StackLayout>
<!-- Place new controls here -->
<Label Text="Welcome to Xamarin.Forms!"
HorizontalOptions="Center"
VerticalOptions="CenterAndExpand" />
</StackLayout>
</ContentPage>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xamarin.Forms;
namespace XamarinTest
{
public partial class MainPage : ContentPage
{
public MainPage()
{
InitializeComponent();
}
}
}
【问题讨论】:
-
图片的构建动作属性是什么?
-
晕haldo,属性是嵌入式资源。非常感谢
-
好的,没关系。文件名是什么?它是否包含任何
-破折号/连字符?如果确实包含-,请尝试用_替换,看看是否有效。 -
Helo haldo 这个名字没有任何 - 或其他字符。在 Android 模拟器中显示图像,但在我的智能手机中没有
-
你能用
Android resource代替Embedded resource吗?这是安卓还是iOS?
标签: c# xaml xamarin xamarin.forms