Gradient View in Xamarin.Forms using Magic Gradients


In this tutorial, we will learn how to implement Gradient view in Xamarin.Forms with very simple steps. To achieve the gradient view, we are using Magic Gradients plugin for Xamarin Forms. Magic Gradients is a NuGet that provide a possibility to add beautiful and enhanced gradients into Xamarin.Forms applications. It supports all common Xamarin platforms, such as Android, iOS and UWP. It is built upon SkiaSharp to draw a simple multi-color or multi-layer engaged gradients. Without further delay, we will skip into the coding part of the article.

Magic Gradient:

Magic Gradients provides GradientView control which is just a surface for SkiaSharp inside. Inside GradientView you need to set GradientSource which is a default container. Inside it you can place single gradients LinearGradient, RadialGradient or multiple gradients with GradientCollection as a top element.

Coding Part:


I have split the coding part into 3 steps as in the following.

  1. Creating new Xamarin.Forms Projects.
  2. Setting up the libraries.
  3. Implementation of the Gradient Views

Step 1: Creating new Xamarin.Forms Projects

  • Create New Project by Selecting New -> Project -> Select Xamarin Cross Platform App and Click OK.
  • Then Select Android and iOS Platforms as shown below with Code Sharing Strategy as PCL or .Net Standard and Click OK.

Step 2: Setting up the libraries

  • We need to install the NuGet package for Magic Gradients by using any of the below methods.
    1. Search for MagicGradients in NuGet browser.
    2. Using Package Manager CLI: “Install-Package MagicGradients”.
    3. Using the .Net CLI: “dotnet add package MagicGradients”.
    4. Editing your csproj file by adding the following and restoring the project.
    <PackageReference Include="MagiGradients" Version="1.0.0" />
  • We should install it only for our "Core" project.

Step 3: Implementation of the Gradient Views

  • Open your designer file and add the following namespace for magic gradient view.
  • After that we can using Magic Gradients as like in the following code snippet. Inside it you can place single gradients LinearGradient, RadialGradient or multiple gradients with GradientCollection as a top element.
  • Here, we have taken LinearGradient as an example.
    <magic:GradientView VerticalOptions="FillAndExpand">
            <magic:LinearGradient Angle="90">
                <magic:GradientStop Color="Orange" Offset="0" />
                <magic:GradientStop Color="#ff0000" Offset="0.6" />
  • We can use gradient collection for more than one gradient sources like below.
    <magic:GradientView VerticalOptions="FillAndExpand">
                <magic:LinearGradient Angle="45">
                    <magic:GradientStop Color="Orange" Offset="0" />
                    <magic:GradientStop Color="#ff0000" Offset="0.6" />
                <magic:LinearGradient Angle="90">
                    <magic:GradientStop Color="#33ff0000" Offset="0.4" />
                    <magic:GradientStop Color="#ff00ff00" Offset="1" />


Download Code

You can download the code from GitHub. If you have doubt, feel free to post comment. If you like this article and is useful to you, do like, share the article & star the repository on GitHub.

Share this

Related Posts

Next Post »


6 August 2020 at 00:49 delete

Great Article
android based projects

Java Training in Chennai

Project Center in Chennai

Java Training in Chennai

projects for cse

The Angular Training covers a wide range of topics including Components, Angular Directives, Angular Services, Pipes, security fundamentals, Routing, and Angular programmability. The new Angular TRaining will lay the foundation you need to specialise in Single Page Application developer. Angular Training

31 August 2020 at 20:01 delete

Serves24 is Best refrigerator repair In Hyderabad We Provided Door Step Repair And Service & Provide best in class. Get 6 months repair guarantee. Book Now just @249/-. at most affordable prices
LG refrigerator repair in Hyderabad
refrigerator repair in Hyderabad
fridges repair Serivces
Samsung refrigerator repair in Hyderabad
IFB washing machine repair in Hyderabad
fridges repairs hyderabad

1 December 2020 at 11:26 delete

The blog was amazing. I really appreciate your hard work. The way of presentation was really great by the way. Being an android app developer is not a small job. As per experts, The focus of the app industry has been user acquisition abbreviated as UA. Normal tactics and the top practices are available in today's world, which one can use to refine their strategy. As UA becomes more costly, so the conversion strategies are getting highly optimized, and there is a change of target towards stronger engagement with current users and having them over time. Recently I had come across a company called LearnInbox👌👌👌, got a chance to study them for a while and believe me!!! they are offering one of the best android app development services in India with a team of highly experienced professionals. Also, they have been stated the best of android app development in late 2020 by many online sources. A group of hard-working and talented people in one place is always a grand success. Try them for sure, Don't waste your hard-earned money at all other places!! Visit them on
Or you can call a professional at 9951394959. #androidx #androidjetpack #androiddeveloperblog #androidappdevelopment.


Please Comment about the Posts and Blog