{"id":13604640,"url":"https://github.com/neworld/spanner","last_synced_at":"2025-10-19T02:46:20.161Z","repository":{"id":146661573,"uuid":"98952556","full_name":"neworld/spanner","owner":"neworld","description":"Simple and fluent spannable builder","archived":false,"fork":false,"pushed_at":"2020-10-10T21:07:38.000Z","size":187,"stargazers_count":107,"open_issues_count":6,"forks_count":6,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-11-07T09:43:12.901Z","etag":null,"topics":["android","android-lib","java-friendly","kotlin-friendly","spannable"],"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/neworld.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2017-08-01T02:55:05.000Z","updated_at":"2024-04-17T14:13:22.000Z","dependencies_parsed_at":"2023-04-14T16:18:48.196Z","dependency_job_id":null,"html_url":"https://github.com/neworld/spanner","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neworld%2Fspanner","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neworld%2Fspanner/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neworld%2Fspanner/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neworld%2Fspanner/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/neworld","download_url":"https://codeload.github.com/neworld/spanner/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228134107,"owners_count":17874604,"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":["android","android-lib","java-friendly","kotlin-friendly","spannable"],"created_at":"2024-08-01T19:00:49.675Z","updated_at":"2025-10-19T02:46:15.122Z","avatar_url":"https://github.com/neworld.png","language":"Java","readme":"[![](https://jitpack.io/v/neworld/spanner.svg)](https://jitpack.io/#neworld/spanner)\n[![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-Spanner-brightgreen.svg?style=flat)](https://android-arsenal.com/details/1/6271)\n[![Build Status](https://travis-ci.org/neworld/spanner.svg?branch=master)](https://travis-ci.org/neworld/spanner)\n[![Javadoc](https://img.shields.io/badge/javadoc-1.0.0-brightgreen.svg)](https://jitpack.io/com/github/neworld/spanner/1.1.0/javadoc/)\n\nThis lib provides simple and fluent API for creating [Android Spannable](https://developer.android.com/reference/android/text/Spannable.html).\nFeatures:\n- Simple and fluent API\n- Helpers to create spans\n- Small method footprint (\u003c200 methods, 29kb AAR package)\n\nThis library focuses on building spannable. \nIf you prefer put full text first and then apply spans, take a look at [another awesome library](https://github.com/jaychang0917/SimpleText)\n\n#### Examples:\n\n```java\nSpannable spannable = new Spanner()\n        .append(\"Original text\\n\\n\")\n        .append(\"Big and blurry\\n\", Spans.sizePX(100))\n        .span(\"blurry\", blur(5.0f, BlurMaskFilter.Blur.SOLID))\n        .append(\"big in DP\\n\", sizeDP(30))\n        .append(\"50% of original size\\n\", scaleSize(0.5f))\n        .append(\"bold\\n\", bold())\n        .append(\"italic\\n\", italic())\n        .append(\"bold and italic\\n\", boldItalic())\n        .append(\"custom typeface\\n\", font(\"sans-serif-black\"))\n        .append(\"strike through\\n\", strikeThrough())\n        .append(\"underline\\n\", underline())\n        .append(\"background\\n\", background(Color.YELLOW))\n        .append(\"foreground\\n\", foreground(Color.RED))\n        .append(\"subscript\\n\", subscript())\n        .append(\"superscript\\n\", superscript())\n        .append(image(context, R.drawable.ic_android_16dp)).append(\"\\n\")\n        .append(\"quite\\n\", quote())\n        .append(\"The quick brown fox jumps over the lazy dog\\n\", bold(), foreground(0xFF904f1c), Spans.quote())\n        .append(\"Custom\\n\", custom(new CustomSpan()))\n        .append(\"Click here\\n\", click(onClickListener))\n        .append(\"http://www.android.com\\n\", url(\"http://www.android.com\"))\n        ;\n```\n\nIt looks like:\n\n![preview](https://i.imgur.com/SRnNRdm.png?1)\n\nYou can manipulate text in many more ways:\n```java\nSpannable spannable = new Spanner(\"The quick brown fox jumps over the lazy dog\")\n        .span(\"fox\", foreground(Color.RED)) // search and span by given text\n        .replace(\"dog\", \"cat\", strikeThrough()) // any number of spans\n        .insert(5, \"foo\", bold(), italic()) // any number of spans\n        .append(\"bar\", underline()); // any number of spans\n```\n\nIf you need custom span, you need span builder:\n```\n//java 7\nSpannable spannable = new Spanner(\"The quick brown fox jumps over the lazy dog\")\n        .span(\"fox\", custom(new SpanBuilder() {\n                 @Override\n                 public Object build() {\n                     return new StyleSpan(Typeface.ITALIC);\n                 }\n             });\n             \n//java 8\nSpannable spannable = new Spanner(\"The quick brown fox jumps over the lazy dog\")\n        .span(\"fox\", custom(() -\u003e new StyleSpan(Typeface.ITALIC));\n        \n//kotlin\nval spannable = Spanner(\"The quick brown fox jumps over the lazy dog\")\n        .span(\"fox\", custom { StyleSpan(Typeface.ITALIC) })\n```\n\n#### Reference\n\nSpans:\n\n|                         |                         |                       |\n| ---                     | ---                     | ---                   |\n| sizePX(int)             | background(int color)   | center()              |\n| sizeDP(int)             | foreground(int color)   | alignmentOpposite()   |\n| sizeSP(int)             | subscript()             | alignmentNormal()     |\n| scaleSize(float)        | superscript()           | bullet(...)           |\n| bold()                  | image(...)              | imageMargin(...)      |\n| italic()                | click(listener)         | leadingMargin(...)    |\n| boldItalic()            | url(url)                | edit(...)             |\n| font(String)            | custom(spanBuilder)     | emboss(...)           |\n| strikeThrough()         | quote()                 | blur(...)             |\n| underline()             | appearance(...)         | locale(...)           |\n| tabStop(where)          | suggestion(...)         | lineBackground(color) |\n| lineHeight(height)      |\n\nText manipulation:\n\n| Methods                                   | Description                                    |\n| ---------------                           | ---------------------------                    |\n| append(text, spans...)                    | appends text                                   |\n| append(image(...))                        | appends image                                  |\n| replace(search, replace, spans...)        | search and replace text                        |\n| span(search, ignoreCase = false, spans...)| search text and apply spans                    |\n| insert(pos, text, spans...)               | insert given text in given position            |\n\n#### How to use\n```\n    allprojects {\n        repositories {\n            ...\n            maven { url 'https://jitpack.io' }\n        }\n    }\n\t\n    dependencies {\n        implementation 'lt.neworld:spanner:1.1.0'\n    }\n```\n\n#### License\n\n```\nCopyright 2017 Andrius Semionovas\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n   http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n```\n","funding_links":[],"categories":["Java"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fneworld%2Fspanner","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fneworld%2Fspanner","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fneworld%2Fspanner/lists"}