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'

    Bild

  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"

    Bild

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.

Gefällt dir dieser Beitrag?

Kaufe Atharv Vishwas Gupta einen Buch

Mehr von Atharv Vishwas Gupta