Skip to content

Instantly share code, notes, and snippets.

@gauravssnl
Forked from nickbutcher/rainbow.xml
Created January 25, 2023 17:09
Show Gist options
  • Select an option

  • Save gauravssnl/40ad26cf9213beeca8f59799a08e9b5e to your computer and use it in GitHub Desktop.

Select an option

Save gauravssnl/40ad26cf9213beeca8f59799a08e9b5e to your computer and use it in GitHub Desktop.
Demonstrating using VectorDrawable gradients to create a rainbow effect. See https://twitter.com/crafty/status/1011922414983352320
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2018 Google Inc.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License
is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
or implied. See the License for the specific language governing permissions and limitations under
the License.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:aapt="http://schemas.android.com/aapt"
android:width="360dp"
android:height="208dp"
android:viewportWidth="360"
android:viewportHeight="208">
<path android:pathData="M0,0 L360,0 L360,208 L0,208 Z">
<aapt:attr name="android:fillColor">
<gradient
android:endX="360"
android:endY="208"
android:startX="0"
android:startY="0"
android:type="linear"
android:tileMode="repeat">
<item
android:color="#FF0064"
android:offset="0.0" />
<item
android:color="#FF0064"
android:offset="0.111111" />
<item
android:color="#FF7600"
android:offset="0.111111" />
<item
android:color="#FF7600"
android:offset="0.222222" />
<item
android:color="#FFD500"
android:offset="0.222222" />
<item
android:color="#FFD500"
android:offset="0.3333333" />
<item
android:color="#8CFE00"
android:offset="0.3333333" />
<item
android:color="#8CFE00"
android:offset="0.444444" />
<item
android:color="#00E86C"
android:offset="0.444444" />
<item
android:color="#00E86C"
android:offset="0.555555" />
<item
android:color="#00F4F2"
android:offset="0.555555" />
<item
android:color="#00F4F2"
android:offset="0.666666" />
<item
android:color="#00CCFF"
android:offset="0.666666" />
<item
android:color="#00CCFF"
android:offset="0.777777" />
<item
android:color="#70A2FF"
android:offset="0.777777" />
<item
android:color="#70A2FF"
android:offset="0.888888" />
<item
android:color="#A96CFF"
android:offset="0.888888" />
<item
android:color="#A96CFF"
android:offset="1.0" />
</gradient>
</aapt:attr>
</path>
</vector>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment