Skip to content

SpannableTag is an Android library that simplifies the use of the Spannable library by allowing developers to apply text styling through custom tags. It supports a variety of styles including color, bold, italic, underline, and more.

Notifications You must be signed in to change notification settings

YosiBs/SpannableTag-Android-Library

Repository files navigation

SpannableTag Library

SpannableTag is an Android library that simplifies the usage of the Spannable library by allowing developers to use custom tags in strings. The library parses these tags and applies the corresponding spannable styles to the text.

pic5

pic5 Features

  • Foreground Color: Apply custom foreground colors using hex codes. For example, <c#ff0000>red text</c#ff0000> will make "red text" appear in red.
  • Background Color: Apply custom background colors using hex codes. For example, <bg#00ff00>green background</bg#00ff00> will make "green background" text have a green background.
  • Bold: Make text bold. For example, <b>bold text</b> will make "bold text" bold.
  • Italic: Make text italic. For example, <i>italic text</i> will make "italic text" italic.
  • Underline: Underline text. For example, <u>underlined text</u> will underline "underlined text".
  • Strikethrough: Apply strikethrough to text. For example, <strike>strikethrough text</strike> will add a strikethrough to "strikethrough text".
  • Text Size: Set custom text sizes. For example, <size.2>large text</size.2> will make "large text" have a size of 2.

pic5 Installation

pic5

Add the following dependency to your build.gradle file:


dependencyResolutionManagement {
	repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
	repositories {
		mavenCentral()
		maven { url 'https://jitpack.io' }
	}
}

dependencies {
    implementation 'com.github.YosiBs:SpannableTag-Android-Library:Tag'
}

pic5 Usage

To use the SpannableTag library, follow these steps:

1. Initialize the SpannableParser


import com.example.spannabletag.SpannableParser;
import android.text.SpannableString;

2. Use Custom Tags in Your String


String text = "hello world";

3. Parse the String and Apply the Styles


SpannableString spannableString = SpannableParser.parse(text);
textView.setText(spannableString);

Supported Tags

Tag Description Example
<b></b> Bold text <b>bold text</b>
<i></i> Italic text <i>italic text</i>
<u></u> Underline text <u>underline text</u>
<strike></strike> Strikethrough text <strike>strikethrough text</strike>
<size.{value}></size.{value}> Set text size <size.2>large text</size.2>
<c#{hex}></c#{hex}> Set text color using hex code <c#ff0000>red text</c#ff0000>

pic5 Example

Input:

pic5

Output:

pic5

pic5 License

SpannableTag is licensed under the MIT License. See the LICENSE file for more information.

pic5 Authors

About

SpannableTag is an Android library that simplifies the use of the Spannable library by allowing developers to apply text styling through custom tags. It supports a variety of styles including color, bold, italic, underline, and more.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages