{"id":13396239,"url":"https://github.com/amulyakhare/TextDrawable","last_synced_at":"2025-03-13T22:31:56.247Z","repository":{"id":22093513,"uuid":"25423296","full_name":"amulyakhare/TextDrawable","owner":"amulyakhare","description":"This light-weight library provides images with letter/text like the Gmail app. It extends the Drawable class thus can be used with existing/custom/network ImageView classes. Also included is a fluent interface for creating drawables and a customizable ColorGenerator.","archived":false,"fork":false,"pushed_at":"2021-09-02T12:32:50.000Z","size":1148,"stargazers_count":3161,"open_issues_count":60,"forks_count":619,"subscribers_count":117,"default_branch":"master","last_synced_at":"2024-10-29T17:55:57.076Z","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/amulyakhare.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":"2014-10-19T09:56:45.000Z","updated_at":"2024-10-18T14:34:47.000Z","dependencies_parsed_at":"2022-09-01T19:03:14.452Z","dependency_job_id":null,"html_url":"https://github.com/amulyakhare/TextDrawable","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amulyakhare%2FTextDrawable","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amulyakhare%2FTextDrawable/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amulyakhare%2FTextDrawable/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amulyakhare%2FTextDrawable/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/amulyakhare","download_url":"https://codeload.github.com/amulyakhare/TextDrawable/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243494082,"owners_count":20299763,"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:42.926Z","updated_at":"2025-03-13T22:31:55.888Z","avatar_url":"https://github.com/amulyakhare.png","language":"Java","readme":"###TextDrawable \nThis light-weight library provides images with letter/text like the Gmail app. It extends the `Drawable` class thus can be used with existing/custom/network `ImageView` classes. Also included is a [fluent interface](http://en.wikipedia.org/wiki/Fluent_interface) for creating drawables and a customizable `ColorGenerator`.\n\n\u003cp align=\"center\"\u003e\u003cimg src =\"https://github.com/amulyakhare/TextDrawable/blob/master/screens/screen1-material.png\" width=\"350\"/\u003e\n\u003cimg src =\"https://github.com/amulyakhare/TextDrawable/blob/master/screens/screen2-material.png\" width=\"350\"/\u003e\n\u003c/p\u003e\n\n###How to use\n\n#### Import with Gradle:\n\n```groovy\nrepositories{\n    maven {\n        url 'http://dl.bintray.com/amulyakhare/maven'\n    }\n}\n\ndependencies {\n    compile 'com.amulyakhare:com.amulyakhare.textdrawable:1.0.1'\n}\n```\n\n####1. Create simple tile:\n\n\u003cp align=\"center\"\u003e\u003cimg src =\"https://github.com/amulyakhare/TextDrawable/blob/master/screens/screen3.png\"/\u003e\n\u003c/p\u003e\n\n```xml\n\u003cImageView android:layout_width=\"60dp\"\n\t       android:layout_height=\"60dp\"\n\t       android:id=\"@+id/image_view\"/\u003e\n```\n**Note:** Specify width/height for the `ImageView` and the `drawable` will auto-scale to fit the size.\n```java\nTextDrawable drawable = TextDrawable.builder()\n                .buildRect(\"A\", Color.RED);\n\nImageView image = (ImageView) findViewById(R.id.image_view);\nimage.setImageDrawable(drawable);\n```\n\n####2. Create rounded corner or circular tiles:\n\n\u003cp align=\"center\"\u003e\u003cimg src =\"https://github.com/amulyakhare/TextDrawable/blob/master/screens/screen6.png\"/\u003e\n\u003c/p\u003e\n\n```java\nTextDrawable drawable1 = TextDrawable.builder()\n                .buildRoundRect(\"A\", Color.RED, 10); // radius in px\n\nTextDrawable drawable2 = TextDrawable.builder()\n                .buildRound(\"A\", Color.RED);\n```\n\n####3. Add border:\n\n\u003cp align=\"center\"\u003e\u003cimg src =\"https://github.com/amulyakhare/TextDrawable/blob/master/screens/screen5.png\"/\u003e\n\u003c/p\u003e\n\n```java\nTextDrawable drawable = TextDrawable.builder()\n                .beginConfig()\n                    .withBorder(4) /* thickness in px */\n                .endConfig()\n                .buildRoundRect(\"A\", Color.RED, 10);\n```\n\n####4. Modify font style:\n\n```java\nTextDrawable drawable = TextDrawable.builder()\n                .beginConfig()\n\t                .textColor(Color.BLACK)\n                    .useFont(Typeface.DEFAULT)\n                    .fontSize(30) /* size in px */\n                    .bold()\n                    .toUpperCase()\n                .endConfig()\n                .buildRect(\"a\", Color.RED)\n```\n\n####5. Built-in color generator:\n\n```java\nColorGenerator generator = ColorGenerator.MATERIAL; // or use DEFAULT\n// generate random color\nint color1 = generator.getRandomColor();\n// generate color based on a key (same key returns the same color), useful for list/grid views\nint color2 = generator.getColor(\"user@gmail.com\")\n\n// declare the builder object once.\nTextDrawable.IBuilder builder = TextDrawable.builder()\n\t\t\t\t.beginConfig()\n\t\t\t\t\t.withBorder(4)\n\t\t\t\t.endConfig()\n\t\t\t\t.rect();\n\n// reuse the builder specs to create multiple drawables\nTextDrawable ic1 = builder.build(\"A\", color1);\nTextDrawable ic2 = builder.build(\"B\", color2);\n``` \n\n####6. Specify the width / height:\n\n```xml\n\u003cImageView android:layout_width=\"wrap_content\"\n\t       android:layout_height=\"wrap_content\"\n\t       android:id=\"@+id/image_view\"/\u003e\n```\n**Note:**  The `ImageView` could use `wrap_content` width/height. You could set the width/height of the `drawable` using code.\n\n```java\nTextDrawable drawable = TextDrawable.builder()\n\t\t\t\t.beginConfig()\n\t\t\t\t\t.width(60)  // width in px\n\t\t\t\t\t.height(60) // height in px\n\t\t\t\t.endConfig()\n                .buildRect(\"A\", Color.RED);\n\nImageView image = (ImageView) findViewById(R.id.image_view);\nimage.setImageDrawable(drawable);\n```\n\n####7. Other features:\n\n1. Mix-match with other drawables. Use it in conjunction with `LayerDrawable`, `InsetDrawable`, `AnimationDrawable`, `TransitionDrawable` etc.\n\n2. Compatible with other views (not just `ImageView`). Use it as background drawable, compound drawable for `TextView`, `Button` etc.\n\n3. Use multiple letters or `unicode` characters to create interesting tiles. \n\n\u003cp align=\"center\"\u003e\u003cimg src =\"https://github.com/amulyakhare/TextDrawable/blob/master/screens/screen7.png\" width=\"350\"/\u003e\u003c/p\u003e\n","funding_links":[],"categories":["Index `(light-weight pages)`","Uncategorized","Index","Java","Libs","\u003ca name=\"Design Res\"\u003eDesign Res\u003c/a\u003e"],"sub_categories":["Uncategorized","\u003cA NAME=\"Widget\"\u003e\u003c/A\u003eWidget","Personal Blog"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Famulyakhare%2FTextDrawable","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Famulyakhare%2FTextDrawable","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Famulyakhare%2FTextDrawable/lists"}