-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of https://github.com/sp00ne/spanning into main
- Loading branch information
Showing
1 changed file
with
64 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,65 @@ | ||
# Spanning | ||
# Spanning [![](https://jitpack.io/v/sp00ne/spanning.svg)](https://jitpack.io/#sp00ne/spanning) | ||
A library to simplify your Spannable usage with many handy extensions | ||
## How to get it | ||
In the `build.gradle` file of your project, include the dependency like so: | ||
``` | ||
dependencies { | ||
implementation 'com.github.sp00ne:spanning:0.1.0' | ||
} | ||
``` | ||
## How to use it | ||
The usage of this library is pretty straight-forward. To start building the spannable, we begin with the simple example of just returing a `SpannedString`: | ||
``` | ||
spannable("some text without any candy") | ||
``` | ||
If you wish to add Spans to it, you simply open up a block, like so: | ||
|
||
### Single span | ||
``` | ||
spannable("some text with candy") { | ||
setTextColor(color) | ||
} | ||
``` | ||
|
||
### Multiple spans | ||
Which will cause the entire text("some text with candy") to get the text color specified in the block. Spans can also be applied on top of eachother like this: | ||
``` | ||
spannable("this has many effects") { | ||
setTextColor(color) | ||
setUnderline() | ||
setStrikethrough() | ||
} | ||
``` | ||
which results in "this has many effects" being colored, underlined and strikethrough. | ||
|
||
### Appending spans | ||
If you wish to append multiple spans, there are supported functions for this in the library. | ||
``` | ||
spannable(first text") appendSpace spannable("second text") | ||
``` | ||
which simply appends and adds a space character inbetween the two. Resulting in `first text second text` It is also possible for a line break like so: | ||
``` | ||
spannable("first text") appendLine spannable("second text on a new line") | ||
``` | ||
results in | ||
``` | ||
first text | ||
second text on a new line | ||
``` | ||
|
||
## What is supported | ||
Running the demo will showcase what is supported. As of right now there is | ||
* `setTextSize` | ||
* `setTextSizeDp` | ||
* `setTextColor` | ||
* `setUnderline` | ||
* `setStrikethrough` | ||
* `setScale` | ||
* `setBold` | ||
* `setItalic` | ||
* `setBackgroundColor` | ||
* `setFont` | ||
* `setTextAppearance` | ||
|
||
## Demo | ||
[![](https://i.ibb.co/LpJm2f2/Screenshot-1605967464.png)] |