我在Android和IOS的Xamarin中都有一个扫描仪应用程序。 当扫描仪成功时,我想显示0.5秒的绿屏。 当它失败时,我想要显示一个红色的屏幕。
但我找不到任何允许我创建该屏幕的代码。
我希望这里的任何人能够把我推向正确的方向。
答案 0 :(得分:1)
我认为当扫描仪成功或失败时,您将拥有回调函数。
在回调函数中,您可以使用BackgroundColor = Color.Red;
来更改背景。
每个页面都有BackgroundColor
属性。例如,我按代码创建了一个底部,然后单击按钮更改页面背景:
public App()
{
InitializeComponent();
var page1 = new ContentPage();
Button changeBgBt = new Button { Text = "change backgroud color", WidthRequest = 100, HeightRequest = 50, VerticalOptions=LayoutOptions.Center, HorizontalOptions = LayoutOptions.Center };
changeBgBt.Clicked += ChangeBgBt_Clicked;
var content = new StackLayout();
content.Children.Add(changeBgBt);
page1.Content = content;
MainPage = page1;
}
private void ChangeBgBt_Clicked(object sender, EventArgs e)
{
MainPage.BackgroundColor = Color.Red;
}