Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/guilhe/androidstyling-lintrules
A set of lint rules to check for common mistakes when styling and theming on Android
https://github.com/guilhe/androidstyling-lintrules
android-colors android-lint android-lint-rule android-style android-theme lint lint-rules material-colors material-design
Last synced: 10 days ago
JSON representation
A set of lint rules to check for common mistakes when styling and theming on Android
- Host: GitHub
- URL: https://github.com/guilhe/androidstyling-lintrules
- Owner: GuilhE
- License: apache-2.0
- Created: 2020-06-17T01:10:10.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2022-08-29T17:19:32.000Z (about 2 years ago)
- Last Synced: 2024-08-03T18:19:59.971Z (4 months ago)
- Topics: android-colors, android-lint, android-lint-rule, android-style, android-theme, lint, lint-rules, material-colors, material-design
- Language: Kotlin
- Homepage: https://guilhe.github.io/AndroidStyling-LintRules
- Size: 753 KB
- Stars: 6
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# AndroidStyling-LintRules
[![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-AndroidStyling--LintRules-brightgreen.svg?style=flat)](https://android-arsenal.com/details/1/8238)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](https://material.io/develop/android/theming/color/).## Installation
AndroidStyling-LintRules is distributed through [Maven Central](https://search.maven.org/artifact/com.github.guilhe/styling-lint) and [Jitpack](https://jitpack.io/#GuilhE/AndroidStyling-LintRules).
```groovy
implementation 'com.github.guilhe:styling-lint:${LATEST_VERSION}'
```
[![Maven Central](https://img.shields.io/maven-central/v/com.github.guilhe/styling-lint.svg)](https://search.maven.org/search?q=g:com.github.guilhe%20AND%20styling-lint)## 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:
```xml```
You'll get a warning advising you to change it:This rules are not exclusive for layouts:
```java
getColor(R.color.colorPrimary)
```
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](https://github.com/GuilhE/ResourcesProvider-ktx) may come in hand. It's a helper class to provide
resources and it has ["themes support"](https://github.com/GuilhE/ResourcesProvider-ktx#themes):
```java
.setBackgroundColor(resourcesProvider.colorRes(R.attr.colorPrimary, R.style.App_Style_A)
```
## Bugs and FeedbackFor bugs, questions and discussions please use the [Github Issues](https://github.com/GuilhE/AndroidStyling-LintRules/issues).
## LICENSE
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 atUnless 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.