Gradient Background in Android Posted By : Prince Bhardwaj | 30-Mar-2018. We have seen the Gradient colors on many websites as backgrounds, used in App logos, like in the Instagram logo shown below, App background, buttons, progress bars, etc. Come to WebGradients.com for 180 beautiful linear gradients in CSS3, Photoshop and Sketch. In this Android gradient background tutorial we’ll teach you how you can create 3 types of gradients i.e, linear, radial and sweep; with their codes. To achieve this, you’ll have to first create a new android drawable resource file. Choose from hundreds of free gradient backgrounds. So you can give 0, 45, 90, 135 and so on. First, let's add two new colours to our XML file from the previous lesson. This collection is curated by top designers and totally free. Home Mobile Android Gradient Background in Android. It may be optional but you can use it if you want, X position of the center point of the gradient within the shape as a fraction of the width, Y-position of the center point of the gradient within the shape as a fraction of the height, The angle of the gradient and it is only used with the linear gradient, It must be multiple of 45 in the range [0, 315], It is used to set the type of gradient and the default value is linear . Create a new file named “gradient_background”. In this video we will create an animated gradient background similar to the one in the Instagram login screen. If you face any issue while doing this, please share it in the comment section below and we will be happy to help. support. Now open the activity_main.xml file and remove the default code and change the layout to RelativeLayout and set it's background to gradient background as shown below: with this our activity_main.xml is done and the complete code will look like: And the output of the above is shown below: We can also add the gradient to different Views and layouts in our Android App. Start the animation in the onCreate method of the Activity of the fragment. Contribute to csdodd/GradientLayout development by creating an account on GitHub. For the android type attribute, we have only two: linear and radial.For you to create gradients, you have to specify at least two colors such as the android:startColor tag and android:endColor tag. The code of gradient_drawable.xml file is shown below: As you can see in the code above, we are using the gradient tag along with providing android:startColor, android:centerColor and android:endColor attributes to define the color that will be used in the gradient. This example demonstrate about how to create Animated Gradient Background in android. Android gradient background styling is the best way to style your background without consuming too much memory or taxing user storage. Android Simple Button -->