{"id":13396428,"url":"https://github.com/chemouna/decor","last_synced_at":"2026-01-23T14:35:07.077Z","repository":{"id":30261815,"uuid":"33813213","full_name":"chemouna/Decor","owner":"chemouna","description":"Android layout decorators : Injecting custom attributes in layout files, Using decorators to get rid of unnecessary class explosion with custom views","archived":false,"fork":false,"pushed_at":"2021-07-29T13:36:41.000Z","size":1667,"stargazers_count":302,"open_issues_count":7,"forks_count":23,"subscribers_count":11,"default_branch":"master","last_synced_at":"2024-07-31T07:17:21.553Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Java","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/chemouna.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-04-12T10:52:59.000Z","updated_at":"2024-01-25T07:12:01.000Z","dependencies_parsed_at":"2022-07-28T01:17:12.928Z","dependency_job_id":null,"html_url":"https://github.com/chemouna/Decor","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chemouna%2FDecor","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chemouna%2FDecor/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chemouna%2FDecor/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chemouna%2FDecor/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chemouna","download_url":"https://codeload.github.com/chemouna/Decor/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221421540,"owners_count":16817825,"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":[],"created_at":"2024-07-30T18:00:51.089Z","updated_at":"2026-01-23T14:35:07.043Z","avatar_url":"https://github.com/chemouna.png","language":"Java","readme":"Decor\n======\n\n\u003ca href='http://android-arsenal.com/details/1/1773'\u003e\u003cimg src='https://img.shields.io/badge/Android%20Arsenal-Decor-brightgreen.svg?style=flat'\u003e\u003c/a\u003e\n\n*Decor* is a library that applies decorators to Android layout with additional attributes\nwithout the need to extend and create a custom View for each functionality.\n\nDecor plugs into Android's layout inflation and applies custom attributes to Views.\n\nIf you have written a custom View like AutofitTextViewWithFont : to make a TextView resize it's text and have a specific font\nand if you want to animate it you can write a custom View like AnimatedAutofitTextViewWithFont and if there's another runtime\ncustom attribute you want to add you will have to yet create another custom View.\n Decor comes to the rescue to solve this unnecessary class explosion by using a separate decorator for each functionality :\n    : AutoFitDecorator , FontDecorator, AnimateDecorator (See decorators module for examples of how to create a decorator)\n     and register them in attachBaseContext :\n     \n```java \n@Override\nprotected void attachBaseContext(Context newBase) {\n   super.attachBaseContext(DecorContextWrapper.wrap(newBase)\n           .with(Decorators.getAll()));\n}\n```\n```xml\n \u003cTextView\n        xmlns:tools=\"http://schemas.android.com/tools\"\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"wrap_content\"\n        android:text=\"I'm a TextView\"\n        app:decorTypefaceAsset=\"Ubuntu-M.ttf\"\n        app:decorAutoFit=\"true\"\n        tools:ignore=\"MissingPrefix\"/\u003e\n```\nor with an ImageView : \n\u003cImageView xmlns:app=\"http://schemas.android.com/apk/res-auto\"\n    xmlns:tools=\"http://schemas.android.com/tools\"\n    xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    android:id=\"@+id/search\"\n    android:layout_gravity=\"center\"\n    android:layout_width=\"150dp\"\n    android:layout_height=\"24dp\"\n    android:src=\"@drawable/search_vector_drawable\"\n    app:decorAnimateSearch=\"true\" /\u003e\n    \nThis has the advantage of reusing these decorators in other Views.\nThe module decorators contains some examples of useful decorators that you can start using now,\nor write your own by extending ``` AttrsDecorator\u003cT\u003e``` where T is the type of the View the decor will be applied on.\n\nIf you want to apply only a subset of decorators :\n\n```java\n@Override\nprotected void attachBaseContext(Context newBase) {\n    super.attachBaseContext(DecorContextWrapper.wrap(newBase)\n            .with(new FontDecorator());\n}\n```\n\nCheck the samples for a working example :\n\n![](images/decor_sample.png)\n\n\nAndroid Studio (lint) will likely mark this XML with a warning despite being correct. You may want to add tools:ignore=\"MissingPrefix\" to either the View itself or its parent ViewGroup to get rid of it. Also add tools namespace xmlns:tools=\"http://schemas.android.com/tools\" to have access to \"ignore\" attribute.\n\nBinaries\n========\n\nBinaries and dependency information for Maven, Ivy, Gradle and others can be found at [http://search.maven.org](http://search.maven.org/#search%7Cga%7C1%7Ccom.mounacheikhna).\n\n\u003ca href='http://search.maven.org/#search%7Cga%7C1%7Ccom.mounacheikhna.decor'\u003e\u003cimg src='http://img.shields.io/maven-central/v/com.mounacheikhna/decor.svg'\u003e\u003c/a\u003e\n\u003ca href='http://search.maven.org/#search%7Cga%7C1%7Ccom.mounacheikhna.decorators'\u003e\u003cimg src='http://img.shields.io/maven-central/v/com.mounacheikhna/decorators.svg'\u003e\u003c/a\u003e\n\nfor Gradle:\n```groovy\ncompile 'com.mounacheikhna:decor:0.2.4'\ncompile 'com.mounacheikhna:decorators:0.2.4'\n```\n\nand for Maven:\n\n```xml\n\u003cdependency\u003e\n    \u003cgroupId\u003ecom.mounacheikhna\u003c/groupId\u003e\n    \u003cartifactId\u003edecor\u003c/artifactId\u003e\n    \u003cversion\u003e0.2.4\u003c/version\u003e\n\u003c/dependency\u003e\n\u003cdependency\u003e\n    \u003cgroupId\u003ecom.mounacheikhna\u003c/groupId\u003e\n    \u003cartifactId\u003edecorators\u003c/artifactId\u003e\n    \u003cversion\u003e0.2.4\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\nand for Ivy:\n\n```xml\n\u003cdependency org=\"com.mounacheikhna\" name=\"decor\" rev=\"0.2.4\" /\u003e\n\u003cdependency org=\"com.mounacheikhna\" name=\"decorators\" rev=\"0.2.4\" /\u003e\n```\n\nWant to help?\n=============\n\nFile new issues to discuss specific aspects of the API or the implementation and to propose new\nfeatures or add new decorators.\n\n\nLicence\n=======\n    Copyright (c) 2013 Madis Pink\n    Copyright (c) 2015 Mouna Cheikhna\n\n    Licensed under the Apache License, Version 2.0 (the \"License\");\n    you may not use this file except in compliance with the License.\n    You may obtain a copy of the License at\n\n        http://www.apache.org/licenses/LICENSE-2.0\n\n    Unless required by applicable law or agreed to in writing, software\n    distributed under the License is distributed on an \"AS IS\" BASIS,\n    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n    See the License for the specific language governing permissions and\n    limitations under the License.\n\nExternal code\n=======\nThis project includes code from third parties:\n[pretty](https://github.com/madisp/pretty) by [Madis Pink](https://github.com/madisp). MIT licence.\n","funding_links":[],"categories":["Index `(light-weight pages)`","Index","Libs"],"sub_categories":["\u003cA NAME=\"Widget\"\u003e\u003c/A\u003eWidget"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchemouna%2Fdecor","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchemouna%2Fdecor","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchemouna%2Fdecor/lists"}