• Stars
    star
    136
  • Rank 267,670 (Top 6 %)
  • Language
    Java
  • License
    MIT License
  • Created over 7 years ago
  • Updated almost 6 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

TextHighlighter for android. Highlights your TextView easily.

Android TextHighlighter

version 1.0.3 API Level โ‰ฅ9 API โ‰ฅ2.3 API โ‰ฅ9 MIT LICENSE javadoc

Introduction

highlights every View which inherits TextView(i.e. TextView, Button, EditText). Set targets and Colors. Then highlight any word.

Sample

Requirements

Android API โ‰ฅ 2.3 (API Level 9)

Gradle

You can import TextHighlighter from jcenter.

repositories {
    jcenter()
}

dependencies {
    compile 'com.xeoh.android:text-highlighter:1.0.3'
}

Usage

// Initialize TextHighlighter
private TextHighlighter textHighlighter = new TextHighlighter()
      .setBackgroundColor(Color.parse("#FFFF00"))
      .setForegroundColor(Color.RED)
      .setBold(true)
      .setItalic(true)
      .addTarget(findViewById(R.id.anyTextView))
      .highlight("word", TextHighlighter.BASE_MATCHER);

// invalidate after add more targets
textHighlighter.addTarget(findViewById(R.id.anyButton))
      .invalidate(TextHighlighter.BASE_MATCHER);

// invalidate after color changes
textHighlighter.setForegroundColor(Color.GREEN)
      .invalidate(TextHighlighter.BASE_MATCHER);

// change matcher to case insensitive
textHighlighter.invalidate(TextHighlighter.CASE_INSENSITIVE_MATCHER);

/*
You can use multiple TextHighlighter for multiple keyword or multiple
styles. However, if two highlighter highlights same word, priority depends
on order of highlight(...) function call
*/

See sample application

Version History

  • 1.0.0 Testing version. (Not published)
  • 1.0.1 First Deploy.
  • 1.0.2 Add bold and italic feature.
  • 1.0.3 Fix Performance issue for large amount of list items.

License

TextHighlighter is available under the MIT license. See the LICENSE file for more info.