Adding Curves and Gradient Colors to Android Views Has Never Been Easier— Android Studio Tutorial (Using XML Only)

Dr Adam Fils
3 min readOct 25, 2019

--

Custom Android Button View

One of the main selling point of your app is it’s UI and plain one ole raw and views don’t cut it when you trying to create an eye catching app.
So today i will be showing how to create and apply curves and gradient colors to an Android in 3 Steps.

1. Create A Drawable File by Right Clicking the Drawable Folder.

Creating A New Drawable File Android Studio
Naming A New Drawable File Android Studio

2. Create 3 tags: <selector> <item> <shape> as shown in photo and within <shape> you define your attributes like

<corners> To Define Curves at The Corners of the View

<stroke> Outer Layer Line as shown in No 2 in First Photo

<solid> Define 1Color You will like to use for your views

<gradient> Defines 2 to 3 colors your will like to use on your views hence creating a gradient.

And lots more but these are the 4 we will be using for this Tutorial.

Example 1:(From Image 1 After Heading)

Creating A Curved Button Drawable on Android Studio
No 1 From Initial Image

Example 2:(From Image 1 After Heading)

Creating A Curved Button Drawable with Stroke on Android Studio
No 2 From Initial Image

Example 3:(From Image 1 After Heading)

Creating A Curved Button Drawable with stroke and gradient on Android Studio
No 3 From Initial Image

3. Set your newly created drawable as the background to the view you want to modify.

Setting View Background Drawable on Android Studio
Custom Android Button View

And Tada!!! 🎉 🎊 There Your Have It Your Custom Curved Drawable 😉 😀 with a fancy gradient to play around with.If you found this helpful clap, share, follow to stay in the Loop. 👍

--

--

Dr Adam Fils

Adam - Google Android Engineer 📱 Passionate coder, problem solver 💡 & vocalist 🎤 Innovating the tech world while hitting the high notes 🎶 Follow my journey!