A set of lint rules to check for common mistakes when styling and theming on Android

android-library, android-lint, android-theme, kotlin-library, lint, material-design


Publish to Bintray Maven Central Download


A set of lint rules to prevent us from the temptation of using HEX values or direct color resources instead of attributes, when creating our layouts either by xml or programmatically.
To refresh your knowledge about theming colors: Material Guidelines.

Getting started

Fetch code
git clone  
cd AndroidStyling-LintRules
Build the validator

./gradlew build

Copy to the lint directory

For all projects: cp styling-lint/build/libs/styling-lint.jar ~/.android/lint/
For a specific project: cp styling-lint/build/libs/styling-lint.jar [path-to-project]/[desired-module]/libs

Configure your build.gradle

lintChecks fileTree(dir: 'libs', include: 'styling-lint.jar')
lintChecks(fileTree(mapOf("dir" to "libs", "include" to "styling-lint.jar"))) (if you use .kts)

Run lint

./gradlew lint

Sample usage

Well this is easy, your styles and layouts should always use attributes to get the color from the corresponding theme.
Therefore, in situations like:


You'll get a warning advising you to change it:

This rules are not exclusive for layouts:


You'll also get a warning advising you to change it:

In code situations, getting a color from a theme is not that trivial and it involves a bit of boilerplate code.
For that reason, ResourcesProvider-ktx may come in hand. It's a helper class to provide resources and it has "themes support":


Bugs and Feedback

For bugs, questions and discussions please use the Github Issues.


Additional binaries and dependency information for can be found here.


Copyright (c) 2020-present GuilhE

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

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.