How to Add a Linear Gradient Background ...

How to Add a Linear Gradient Background in Android Studio

Aug 03, 2021

Hi there! In this post, I will tell you how to add a linear gradient background to an activity in android studio. The steps are listed below:

  1. Create a new file in the drawable folder called background.xml. Set the Root element to 'shape'

    immagine

  2. Add the following code:

    <gradient
        android:startColor="#0D973B"
        android:endColor="#1295B6" />

    The gradient element allows us to make a gradient.

  3. To add the gradient to your activity, add the background attribute in the head element. Set the value of the background attribute to "@drawable/background"

    android:background="@drawable/filename"

    immagine

So this is how you add a linear gradient background to an activity. If this post helped you, consider getting me some books. Bye for now.

Ti piace questo post?

Offri un libro a Atharv Vishwas Gupta

Altro da Atharv Vishwas Gupta