{"id":19915745,"url":"https://github.com/maoruibin/onedrawable","last_synced_at":"2026-01-31T15:32:34.545Z","repository":{"id":91596829,"uuid":"87282503","full_name":"maoruibin/OneDrawable","owner":"maoruibin","description":":pencil2: Use only one image to set a background with a click effect for the View","archived":false,"fork":false,"pushed_at":"2017-09-23T15:49:16.000Z","size":162,"stargazers_count":294,"open_issues_count":3,"forks_count":35,"subscribers_count":11,"default_branch":"master","last_synced_at":"2025-04-20T21:35:32.580Z","etag":null,"topics":["android","android-library","background","drawable","drawables","select","state"],"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/maoruibin.png","metadata":{"files":{"readme":"Readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2017-04-05T07:57:30.000Z","updated_at":"2024-01-04T16:12:56.000Z","dependencies_parsed_at":"2024-01-14T11:09:51.731Z","dependency_job_id":"1d9b19d6-79eb-47b8-818c-4e6377442c4d","html_url":"https://github.com/maoruibin/OneDrawable","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/maoruibin/OneDrawable","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maoruibin%2FOneDrawable","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maoruibin%2FOneDrawable/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maoruibin%2FOneDrawable/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maoruibin%2FOneDrawable/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/maoruibin","download_url":"https://codeload.github.com/maoruibin/OneDrawable/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maoruibin%2FOneDrawable/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28946778,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-31T14:26:55.697Z","status":"ssl_error","status_checked_at":"2026-01-31T14:26:52.545Z","response_time":128,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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","background","drawable","drawables","select","state"],"created_at":"2024-11-12T21:42:16.614Z","updated_at":"2026-01-31T15:32:34.530Z","avatar_url":"https://github.com/maoruibin.png","language":"Java","readme":"# OneDrawable\n\n[![Build Status](https://travis-ci.org/maoruibin/OneDrawable.svg?branch=master)](https://travis-ci.org/maoruibin/OneDrawable)\n[![](https://img.shields.io/hexpm/l/plug.svg)](https://github.com/maoruibin/OneDrawable/blob/master/LICENSE.txt)\n[![](https://jitpack.io/v/maoruibin/OneDrawable.svg)](https://jitpack.io/#maoruibin/OneDrawable)\n\n![OneDrawable](http://7xr9gx.com1.z0.glb.clouddn.com/slogin.gif)\n\nOnly use one drawable/color resource to set the background of the View. | [OneDrawable - 仅使用一张资源图片为 View 设置具有按下效果的背景](http://gudong.name/2017/04/05/OneDrawable.html)\n\n## Sample\nPlease see the [sample app](https://github.com/maoruibin/OneDrawable/tree/master/app/src/main/java/name/gudong/demo) for a library usage example.\n\n[sample apk](https://fir.im/leku)\n\nshot \n\n![demo](http://7xr9gx.com1.z0.glb.clouddn.com/statebackgroundv2.gif)\n\n## Gradle\n\n```\ndependencies {\n    compile 'name.gudong:one-drawable:1.1.1'\n}\n```\n\n## Usage\ncommon usage\n\n```java\nDrawable drawable = OneDrawable.createBgDrawable(this,R.drawable.ic_action_name);\ntvIcon1.setBackgroundDrawable(drawable);\n```\n\n## common api\n\n * createBgDrawable (use drawable resource create a background)\n * createBgColor (use color resource create a background)\n\n### indicate pressed mode\n\npressed state with dark mode. In this mode, drawable will automatically cover a layer of dark when pressed.\n\ndrawable background\n\n```java\nDrawable icon1 = OneDrawable.createBgDrawableWithDarkMode(this,R.drawable.ic_action_name);\ntvIcon1.setBackgroundDrawable(icon1);\n```\n\ncolor background \n\n```java\nDrawable color2 = OneDrawable.createBgColor(this,R.color.colorAccent);\ntvColor2.setBackgroundDrawable(color2);\n```\n\npressed state with alpha mode. In this mode, drawable will automatically change alpha value to 0.7 when pressed.\n\n```java\nDrawable icon3 = OneDrawable.createBgDrawableWithAlphaMode(this,R.drawable.ic_action_add);\ntvIcon3.setBackgroundDrawable(icon3);\n```\n\n### Custom Alpha value\n\nSometimes, maybe you need custom alpha value, you can use methods like follows.\n \n```java\nDrawable icon2 = OneDrawable.createBgDrawableWithDarkMode(this,R.drawable.ic_action_add,0.4f);\ntvIcon2.setBackgroundDrawable(icon2);\n\nDrawable icon4 = OneDrawable.createBgColorWithAlphaMode(this,R.drawable.ic_action_name,0.3f);\ntvIcon4.setBackgroundDrawable(icon4);\n\nDrawable icon4 = OneDrawable.createBgColorWithDarkMode(this,R.color.colorAccent,0.3f);\ntvIcon4.setBackgroundDrawable(icon4);\n\n\nDrawable icon4 = OneDrawable.createBgColorWithAlphaMode(this,R.color.colorAccent,0.3f);\ntvIcon4.setBackgroundDrawable(icon4);\n\n``` \n\nNote: `Because of only clickable view show it's pressed drawable, so you should set view clickable as true before you want to watch pressed effect.`\n\n## Author\n[http://gudong.name](http://gudong.name)\n\n[https://github.com/maoruibin](https://github.com/maoruibin)\n\n[http://weibo.com/maoruibin](http://weibo.com/maoruibin)\n\n## License\n\n    Copyright 2017 GuDong\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\n\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaoruibin%2Fonedrawable","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmaoruibin%2Fonedrawable","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaoruibin%2Fonedrawable/lists"}