How to Set Android Gradient Background Multiple Colors

In an article that I published on Dec. 23, 2018, entitled How to set Gradient Background colors in Android Studio, only explained for limited colors. This article will explain How to Set Android Gradient Background Multiple Colors. Yes, many colors.

Currently, on November 16, 2019, I am using:

  • Android Studio version 3.5
  • Build #AI-191.8026.42.35.5791312, built on August 9, 2019
  • JRE: 1.8.0_202-release-1483-b49-5587405 amd64
  • JVM: OpenJDK 64-Bit Server VM by Jetbrains s.r.o

Step to Make Gradient Background Multiple Colors in Android Studio

  • Open your Android Studio.
  • Make a project and give it the name you like.
  • In the Drawable folder, create a file called Gradient or another name that you want.
Make Gradient Background Multiple Colors in Android Studio
Make Gradient Background Multiple Colors in Android Studio
<vector xmlns:android=”http://schemas.android.com/apk/res/android”
xmlns:aapt=”http://schemas.android.com/aapt”
android:width=”100dp”
android:height=”100dp”
android:viewportWidth=”1″
android:viewportHeight=”800″>
<path android:pathData=”M0,870l0,-870l987,0l0,870z”>
<aapt:attr name=”android:fillColor”>
<gradient
android:endX=”1″
android:endY=”870″
android:startX=”1″>
<item
android:color=”#FF5252″
android:offset=”0″/>
<item
android:color=”#69F0AE”
android:offset=”0.1974″/>
<item
android:color=”#E040FB”
android:offset=”0.3786″/>
<item
android:color=”#FFD740″
android:offset=”0.5906″/>
<item
android:color=”#FF6E40″
android:offset=”0.7513″/>
<item
android:color=”#64FFDA”
android:offset=”1″/>
</gradient>
</aapt:attr>
</path></vector>
  • Source: https://stackoverflow.com, thank you for the source.
  • The last step, open activity_main.xml then add the following line of code: android: background = “@drawable/gradient”
android: background = "@drawable/gradient"
Add android: background = “@drawable/gradient”
  • Here are the results if you follow the steps above.
Gradient Background Multiple Colors
Gradient Background Multiple Colors

I hope this article helps many people. Share to your social media so that more people can be helped with this

Thank you.

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *