{"id":15626131,"url":"https://github.com/skydoves/rainbow","last_synced_at":"2025-04-04T12:07:05.131Z","repository":{"id":49770559,"uuid":"204112535","full_name":"skydoves/Rainbow","owner":"skydoves","description":"🌈 Fluent syntactic sugar of Android for applying gradations, shading, and tinting.","archived":false,"fork":false,"pushed_at":"2021-06-10T02:34:09.000Z","size":283,"stargazers_count":452,"open_issues_count":0,"forks_count":17,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-03-28T11:07:22.971Z","etag":null,"topics":["android","android-library","gradation","gradient","kotlin","rainbow","skydoves","tint","tinting"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/skydoves.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null},"funding":{"github":"skydoves","custom":["https://www.paypal.me/skydoves","https://www.buymeacoffee.com/skydoves"]}},"created_at":"2019-08-24T05:23:08.000Z","updated_at":"2025-01-10T03:22:02.000Z","dependencies_parsed_at":"2022-08-30T09:11:11.429Z","dependency_job_id":null,"html_url":"https://github.com/skydoves/Rainbow","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skydoves%2FRainbow","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skydoves%2FRainbow/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skydoves%2FRainbow/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skydoves%2FRainbow/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/skydoves","download_url":"https://codeload.github.com/skydoves/Rainbow/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247174417,"owners_count":20896078,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","android-library","gradation","gradient","kotlin","rainbow","skydoves","tint","tinting"],"created_at":"2024-10-03T10:10:52.045Z","updated_at":"2025-04-04T12:07:05.114Z","avatar_url":"https://github.com/skydoves.png","language":"Kotlin","readme":"# Rainbow\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://opensource.org/licenses/Apache-2.0\"\u003e\u003cimg alt=\"License\" src=\"https://img.shields.io/badge/License-Apache%202.0-blue.svg\"/\u003e\u003c/a\u003e\n  \u003ca href=\"https://android-arsenal.com/api?level=16\"\u003e\u003cimg alt=\"API\" src=\"https://img.shields.io/badge/API-16%2B-brightgreen.svg?style=flat\"/\u003e\u003c/a\u003e\n  \u003ca href=\"https://travis-ci.org/skydoves/Rainbow\"\u003e\u003cimg alt=\"BuildStatus\" src=\"https://travis-ci.org/skydoves/Rainbow.svg?branch=master\"/\u003e\u003c/a\u003e\n   \u003ca href=\"https://androidweekly.net/issues/issue-398\"\u003e\u003cimg alt=\"Android Weekly\" src=\"https://img.shields.io/badge/Android%20Weekly-%23398-orange\"/\u003e\u003c/a\u003e\n  \u003ca href=\"https://us12.campaign-archive.com/?u=f39692e245b94f7fb693b6d82\u0026id=febdf46615\"\u003e\u003cimg alt=\"KotlinWeekly\" src=\"https://img.shields.io/badge/KotlinWeekly-%23165-4E71E6\"/\u003e\u003c/a\u003e\n  \u003ca href=\"https://skydoves.github.io/libraries/rainbow/javadoc/rainbow/com.skydoves.rainbow/index.html\"\u003e\u003cimg alt=\"Javadoc\" src=\"https://img.shields.io/badge/Javadoc-Rainbow-yellow\"/\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n🌈 Fluent syntactic sugar of Android for applying gradations, shading, and tinting.\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n\u003cimg src=\"https://user-images.githubusercontent.com/24237865/63633474-2a597800-c684-11e9-8aa3-db99575c73e0.png\" width=\"694\" height=\"235\"/\u003e\n\u003c/p\u003e\n\n## Download\n[![Maven Central](https://img.shields.io/maven-central/v/com.github.skydoves/rainbow.svg?label=Maven%20Central)](https://search.maven.org/search?q=g:%22com.github.skydoves%22%20AND%20a:%22rainbow%22)\n[![Jitpack](https://jitpack.io/v/skydoves/Rainbow.svg)](https://jitpack.io/#skydoves/Rainbow)\n#### Gradle\nAdd below codes to your **root** `build.gradle` file (not your module build.gradle file).\n```gradle\nallprojects {\n    repositories {\n        mavenCentral()\n    }\n}\n```\nAnd add a dependency code to your **module**'s `build.gradle` file.\n```gradle\ndependencies {\n    implementation \"com.github.skydoves:rainbow:1.0.4\"\n}\n```\n\n## SNAPSHOT \n[![Rainbow](https://img.shields.io/static/v1?label=snapshot\u0026message=rainbow\u0026logo=apache%20maven\u0026color=C71A36)](https://oss.sonatype.org/content/repositories/snapshots/com/github/skydoves/rainbow/) \u003cbr\u003e\nSnapshots of the current development version of Rainbow are available, which track [the latest versions](https://oss.sonatype.org/content/repositories/snapshots/com/github/skydoves/rainbow/).\n```Gradle\nrepositories {\n   maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' }\n}\n```\n\n## Usage\nWe can apply gradations and tinting to any views easily using `Rainbow` class.\n\n### Palette\nPalette lambda expression collects colors for creating gradation.\u003cbr\u003e\nWe can collect colors using `contextColor` and `color` functions.\u003cbr\u003e\n`contextColor` gets a __resource__ color from your `colors.xml` file, and `color` gets a __ColorInt__ color.\u003cbr\u003e\nThey should be used with `+` operator in the palette lambda expression.\n\n```kotlin\nRainbow(myCardView).palette { // constructs a palette for collecting colors.\n  +contextColor(R.color.red_200) // getting a color from the resource\n  +contextColor(R.color.yellow_200)\n  +contextColor(R.color.green_200)\n  +contextColor(R.color.blue_200)\n  +color(Color.WHITE) // getting a color\n}.withAlpha(225) // sets alpha (0~255)\n .foreground() // applies gradations to myCardView\n```\n\nHere is kotlin extension ways to apply gradations using `View.rainbow()` method to views.\n\n```kotlin\nmyLinearLayout.rainbow().palette {\n  +contextColor(R.color.skyBlue)\n  +contextColor(R.color.colorPrimary)\n}.background(orientation = RainbowOrientation.TOP_BOTTOM, radius = 8)\n```\n\n\u003cimg src=\"https://user-images.githubusercontent.com/24237865/63633706-6c37ed80-c687-11e9-9316-b29530c7f1a8.jpg\" align=\"right\" width=\"32%\"/\u003e\n\n### Background, Foreground\nWe can apply gradations composed with palette colors to the view's background or foreground.\u003cbr\u003e\nThe `foreground()` method can be applied to your `CardView` or something others.\n\n```kotlin\nRainbow(myCardView).palette {\n  +contextColor(R.color.red_200)\n  +contextColor(R.color.yellow_200)\n}.background() or .foreground()\n```\n\nAnd we can control the gradient orientation and corner radius. \u003cbr\u003e\nWe can use 8 kinds of orientation which `RainbowOrientation`.\n```kotlin\nbackground(orientation = RainbowOrientation.RIGHT_LEFT, radius = 8)\nbackground(orientation = RainbowOrientation.TOP_BOTTOM, radius = 8)\nforeground(RainbowOrientation.DIAGONAL_TOP_LEFT, 8)\nforeground(RainbowOrientation.DIAGONAL_BOTTOM_RIGHT, 8)\n```\n\n\u003cimg src=\"https://user-images.githubusercontent.com/24237865/117522706-bf82d880-afef-11eb-9d1a-17bc90c07fc6.jpg\" align=\"right\" width=\"32%\"/\u003e\n\n### Shade\nWe can shade gradations on a TextView using `Rainbow` class.\n\n```kotlin\ntextView.rainbow().palette {\n  +contextColor(R.color.colorPrimary)\n  +contextColor(R.color.md_orange_100)\n  +contextColor(R.color.md_yellow_100)\n  +contextColor(R.color.md_green_200)\n  +contextColor(R.color.md_blue_200)\n  +contextColor(R.color.md_purple_100)\n}.shade()\n```\n\nAlso, we can apply a color array using an array resource in our XML.\n\n```kotlin\ntextView.rainbow().palette {\n  +colorArray(R.array.rainbow)\n}.shade()\n```\n\nHere is a Java way.\n\n```java\nnew Rainbow(textView)\n  .addContextColor(R.color.md_red_400)\n  .addContextColor(R.color.md_yellow_100)\n  .addContextColor(R.color.md_green_100)\n  .addContextColor(R.color.md_blue_100)\n  .addContextColor(R.color.white)\n  .shade();\n```\n\n### Tinting\nWe can change some kinds of view's tint colors which can be applied tint.\u003cbr\u003e\nHere are views can be applied tint: TextView(drawable), ImageView, [CompoundButton](https://developer.android.com/reference/android/widget/CompoundButton), [TintableBackgroundView](https://developer.android.com/reference/androidx/core/view/TintableBackgroundView).\n\n```kotlin\nRainbow(myCheckBox).palette {\n  +contextColor(R.color.red_200)\n}.tint()\n```\n\n### Drawable\nWe can get a `GradientDrawable` using `getDrawable` method. \u003cbr\u003e\n\n```kotlin\nval drawable = Rainbow(myCheckBox).palette {\n  +contextColor(R.color.red_200)\n  +contextColor(R.color.yellow_200)\n}.getDrawable()\n```\n\n### RainbowView\nRainbowView is a gradient view for implementing gradations. \u003cbr\u003e\u003cbr\u003e\nAdd following XML namespace inside your XML layout file.\n\n```gradle\nxmlns:app=\"http://schemas.android.com/apk/res-auto\"\n```\n\n\u003cimg src=\"https://user-images.githubusercontent.com/24237865/63634479-f8e7a900-c691-11e9-99b7-c40651a593f0.gif\" align=\"right\" width=\"33%\"/\u003e\n\n#### RainbowView in xml layout\n```gradle\n\u003ccom.skydoves.rainbow.RainbowView\n  android:id=\"@+id/rainbow\"\n  android:layout_width=\"match_parent\"\n  android:layout_height=\"match_parent\"\n  app:rainbowView_colors=\"@array/colors\" // colors for gradient.\n  app:rainbowView_orientation=\"left_right\" // gradient orientation.\n  app:rainbowView_radius=\"12dp\" // corner radius.\n/\u003e\n```\n\nThe `rainbowView_colors` attributes gets color list from the color-array from your `colors.xml`.\n\n```gradle\n\u003cresources\u003e\n  \u003ccolor name=\"colorPrimary\"\u003e#C51162\u003c/color\u003e\n  ...\n  \u003carray name=\"colors\"\u003e\n    \u003citem\u003e@color/red_100\u003c/item\u003e\n    \u003citem\u003e@color/orange_100\u003c/item\u003e\n    \u003citem\u003e@color/yellow_100\u003c/item\u003e\n    \u003citem\u003e@color/green_100\u003c/item\u003e\n    ...\n  \u003c/array\u003e\n\u003c/resources\u003e\n```\n\n### BinaryRainbowView\nBinaryRainbowView is a gradient view for implementing a simple view with gradations.\n\n```gradle\n\u003ccom.skydoves.rainbow.BinaryRainbowView\n  android:layout_width=\"match_parent\"\n  android:layout_height=\"80dp\"\n  app:binaryRainbowView_startColor=\"@color/md_green_100\" // starting color of the gradient.\n  app:binaryRainbowView_centerColor=\"@color/white\" // center color of the gradient.\n  app:binaryRainbowView_endColor=\"@color/skyBlue\" // end color of the gradient.\n  app:binaryRainbowView_orientation=\"bottom_top\" // gradient orientation.\n  app:binaryRainbowView_radius=\"12dp\" // corner radius\n/\u003e\n```\n\n### Shuffle\n`RainbowView` and `BinaryRainbowView` provides shuffling the palette colors using `shuffleColors()` method. The gradation colors placement will be changed randomly.\n```kotlin\nrainbow.shuffleColors()\n```\n\n### Usage in Java\nHere are some usages for Java developers.\n\n```java\nnew Rainbow(myView)\n    .addContextColor(R.color.red_100)\n    .addContextColor(R.color.orange_100)\n    .addContextColor(R.color.yellow_100)\n    .addContextColor(R.color.green_100)\n    .withAlpha(255)\n    .background(RainbowOrientation.RIGHT_LEFT, 8);\n```\n\n## Find this library useful? :heart:\nSupport it by joining __[stargazers](https://github.com/skydoves/Rainbow/stargazers)__ for this repository. :star:\n\n# License\n```xml\nCopyright 2019 skydoves (Jaewoong Eum)\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n   http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n","funding_links":["https://github.com/sponsors/skydoves","https://www.paypal.me/skydoves","https://www.buymeacoffee.com/skydoves"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fskydoves%2Frainbow","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fskydoves%2Frainbow","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fskydoves%2Frainbow/lists"}