Small & simple library to create a link url, mail, mention, tag and text highlighter in textView.
Switch branches/tags
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
gradle/wrapper 3.0 Sep 13, 2018
library
LICENSE
README.md
build.gradle
gradle.properties
gradlew 3.0 Sep 13, 2018
gradlew.bat 3.0 Sep 13, 2018
settings.gradle

README.md

Android-WordToSpan

Android Arsenal Release

Small & simple library to create a link url, mail, mention, tag and text highlighter in textView.

Gradle

allprojects {
   repositories {
      ...
      maven { url 'https://jitpack.io' }
   }
}
dependencies {
    ...
    compile 'com.github.bachors:Android-WordToSpan:3.1'
}

Create Link

gif

String myText = "I know http://just.com/anu how to @whisper, And I #know just #how to cry,I know just @where to anu@find.com the answers";
TextView tv = (TextView)findViewById(R.id.tx);

WordToSpan link = new WordToSpan();
link.setColorTAG(Color.GREEN)
	.setColorURL(Color.MAGENTA)
	.setColorPHONE(Color.RED)
	.setColorMAIL(getResources().getColor(R.color.colorPrimary))
	.setColorMENTION(getResources().getColor(R.color.colorAccent))
	.setUnderlineURL(true)
	.setLink(myText)
	.into(tv)
	.setClickListener(new WordToSpan.ClickListener() {
		@Override
		public void onClick(String type, String text) {
			// type: "tag", "mail", "url", "phone", "mention" or "custom"
			Toast.makeText(getApplication(), "Type: " + type + "\nText: " + text, Toast.LENGTH_LONG).show();
		}
	});

Create Highlight

gif

String myText = "Any code and resources in the Android library anywhere love code.";
String keyWord = "any code";
TextView tv = (TextView)findViewById(R.id.tx);

WordToSpan highlight = new WordToSpan();
highlight.setBackgroundHIGHLIGHT(Color.YELLOW)
	.setColorHIGHLIGHT(Color.RED)
	.setHighlight(myText, keyWord)
	.into(tv);

MIT