Xamarin 屏幕始终为空白
Xamarin screen is always blank
我正在尝试学习使用 xamarin 创建移动应用程序。我创建了一个简单的应用程序,它在 mainpage.xaml.
上写着 "hello World"
下面是 mainpage.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:App1"
x:Class="App1.MainPage">
<ContentPage.Content>
<StackLayout>
<Label
Text="Welcome to Hello World website" />
<Label Text="A Second Line" FontSize="Large"></Label>
</StackLayout>
</ContentPage.Content>
<Label Text="Welcome to Xamarin Forms!"
VerticalOptions="Center"
HorizontalOptions="Center" />
</ContentPage>
我使用 android sdk 管理器安装了所有更新,我正在使用 Visual studio 2017。当我 运行 应用程序时,我不断收到此错误:
C:\PROGRA~2\Android\ANDROI~1\tools\emulator.EXE -partition-size 512 -no-boot-anim -avd VisualStudio_android-23_arm_phone -prop monodroid.avdname=VisualStudio_android-23_arm_phone
3>emulator: ERROR: cmd_camera_device_start_capturing: Device 'AndroidEmulatorVC0' is unable to save frame to the clipboard: 0
模拟器屏幕总是黑的。我在模拟器屏幕上看不到任何东西。下面是 android SDK 管理器的屏幕截图。我不确定我是否遗漏了任何更新。
任何帮助将不胜感激。
不幸的是 Android 模拟器在稳定性和性能方面的名声很差。您可能想尝试描述如何解决问题的 alternatives. There is one blogpost in Japanese(使用 Google 翻译)。
此外,共享的 XAML 示例无效。 ContentPage
只能包含一个根元素,示例中有2个。所以应该是:
<?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:App1"
x:Class="App1.MainPage">
<ContentPage.Content>
<StackLayout>
<Label Text="Welcome to Hello World website" />
<Label Text="A Second Line" FontSize="Large" />
</StackLayout>
</ContentPage.Content>
</ContentPage>
除此之外我强烈推荐使用 XAMLC,它会在编译时让你知道你的 XAML 是否有任何问题。
我正在尝试学习使用 xamarin 创建移动应用程序。我创建了一个简单的应用程序,它在 mainpage.xaml.
上写着 "hello World"下面是 mainpage.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:App1"
x:Class="App1.MainPage">
<ContentPage.Content>
<StackLayout>
<Label
Text="Welcome to Hello World website" />
<Label Text="A Second Line" FontSize="Large"></Label>
</StackLayout>
</ContentPage.Content>
<Label Text="Welcome to Xamarin Forms!"
VerticalOptions="Center"
HorizontalOptions="Center" />
</ContentPage>
我使用 android sdk 管理器安装了所有更新,我正在使用 Visual studio 2017。当我 运行 应用程序时,我不断收到此错误:
C:\PROGRA~2\Android\ANDROI~1\tools\emulator.EXE -partition-size 512 -no-boot-anim -avd VisualStudio_android-23_arm_phone -prop monodroid.avdname=VisualStudio_android-23_arm_phone
3>emulator: ERROR: cmd_camera_device_start_capturing: Device 'AndroidEmulatorVC0' is unable to save frame to the clipboard: 0
模拟器屏幕总是黑的。我在模拟器屏幕上看不到任何东西。下面是 android SDK 管理器的屏幕截图。我不确定我是否遗漏了任何更新。
任何帮助将不胜感激。
不幸的是 Android 模拟器在稳定性和性能方面的名声很差。您可能想尝试描述如何解决问题的 alternatives. There is one blogpost in Japanese(使用 Google 翻译)。
此外,共享的 XAML 示例无效。 ContentPage
只能包含一个根元素,示例中有2个。所以应该是:
<?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:App1"
x:Class="App1.MainPage">
<ContentPage.Content>
<StackLayout>
<Label Text="Welcome to Hello World website" />
<Label Text="A Second Line" FontSize="Large" />
</StackLayout>
</ContentPage.Content>
</ContentPage>
除此之外我强烈推荐使用 XAMLC,它会在编译时让你知道你的 XAML 是否有任何问题。