How to Create Gradient Background in Android

how to create gradient android

How to Create Gradient Background in Android

The mobile app holds much importance nowadays people are spending more and more time on their Smartphone and this is the reason why mobile apps are so popular nowadays. Android is one of the most used OS which holds almost 48% of market share when it comes to Smartphone OS usage.

Gradient Backgrounds are used majorly in android app development to give very good eye-catching design factors in screen designing. In this Blog, we will see a simple and impactful tutorial on how to create Gradient Background in Android app development.

Step 1:

To Begin, we will first create an XML file where we are going to implement the gradient specifications. Named it bg_gradient.xml. Let us put this XML file under /res/drawable directory.

Step 2:

Next, place this code below the XML tags.

<?xml version="1.0" encoding="UTF-8"?>





As you can notice, we have a gradient tag, together with its attributes. For the android type attribute, we have only two types linear and radial. For you to create gradients, you have to specify a minimum of two colors such as the android:startColortag and android:endColor tag.

And don’t forget to save the created file. After that, you can link your layout’s background to the one you’ve recently created in following way.

Step 3:

Now you can use this created gradient drawable file into any layout components easily as below.

<?xml version="1.0" encoding="utf-8"?>
android:background="@drawable/bg_gradient "


That`s it. This is How to create Gradient Background in Android. Mobile App is gaining more and more popularity as each day passes as Smartphone users are increasing all over the world so it is the right time for your business to have mobile apps. For any other query or to develop Android mobile application, you can hire our dedicated android developers who can solely work for you. You can reach us at for your android app development requirement.