How to make Gradient Background in Android Studio

How to make Gradient Background in Android Studio


Gradient is an effect in which one color fades into another.We will make gradient for background of screen.It can be made for different purposes like for buttons or any other widgets in android.So we will make it using xml drawable resource file.


Step 1.

              Let's create new project in android studio.



Step 2.

              Now Right click on drawable folder under res directory then click new and then select Drawable resource file.




Step 3.

             Now write name gradient, choose root element "shape" and click OK .



It will look like this.

             



Step 4.

             Now write code to make gradient.Take shape attribute in Root Element shape tag then write gradient tag between shape tag.Now under gradient tag Choose start color, end color, angle and type.Values of these attributes can be changed according to your requirements.for example: type attribute has two values either linear or radial.Angle can also be adjusted.



Step 5.

           Now select gradient as background of activity in which you want to use it like:  activity_main.xml file.


   It's Done.You can use different color combinations, angles and types to make your desired gradient. Share your ideas in comments.

Comments

Post a Comment

Popular posts from this blog

Top 10 Wallpaper Android Apps

Blood Donors Using Firebase