D. J.
D. J.

Reputation: 704

Xamarin change full screen color

I have a scanner app build in Xamarin for Android and IOS. When the scanner succeed I want to show a green screen of 0,5 seconds. And when it fails I want to show a red screen.

But I can't find any code that allows me to create that screen.

I hope anyone here can push me in the right direction.

Upvotes: 2

Views: 502

Answers (1)

Mike Ma
Mike Ma

Reputation: 2027

I think you will have a callback function when scanner succeed or fails. In the callback function you can use BackgroundColor = Color.Red; to change the background.

Every page have the BackgroundColor property. For example I created a bottom by code and click the button to change the page background:

        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;
        } 

Upvotes: 1

Related Questions