Skip to content

noah20/Mentions-TextView

Repository files navigation

Mentions Textview

Custome Textview with Mentions and hashtags being clickable.

Download

Step 1. Add it in your root build.gradle at the end of repositories: may be you need to add maven to settings.gradle file

allprojects {
	repositories {
		...
		maven { url 'https://jitpack.io' }
	}
}

Step 2. Add the dependency

dependencies {
	implementation 'com.github.noah20:mentions-textview:last_version'
}

How to use

in your xml layout add this block of code

    <com.sol.textviewutils.SocialTextView
        android:id="@+id/socialTextView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="hello #world from @Home"
        android:padding="7dp"
        android:textColor="#DDD5D5"
        app:boldMentionText="true"
        app:boldHashText="true"
        app:highlightColor="#EA80FC"
        app:hashColor="#80D8FF"
        app:mentionColor="#FF8A80"
        app:tagType="hash|mention" />

and in activity set callback listener to handle action

socialTextView.setSocialCallback(object :OnViewClick{
	override fun onHashClick(tag: String) {
	    // do action here 
	}

	override fun onMentionClick(mention: String) {
	    // do action here 
	}

    })

also you can update textview attr by code like

with(socialTextView){
   mentionColor = android.graphics.Color.RED
   hashColor  = android.graphics.Color.YELLOW
   boldMentionText = true
   boldHashText = true
   type = SocialTextView.FLAG_HASH
}

Screenshots

App Screenshot