AutoLinkTextView is TextView that supports Hashtags (#), Mentions (@) , URLs (http://), Phone and Email automatically detecting and ability to handle clicks.

Last update: Jun 9, 2022

AutoLinkTextView

Android Arsenal

Deprecated

Please use the new version of AutoLinkTextView

AutoLinkTextView is TextView that supports Hashtags (#), Mentions (@) , URLs (http://), Phone and Email automatically detecting and ability to handle clicks.

The current minSDK version is API level 14 Android 4.0 (ICE CREAM SANDWICH).

Download sample apk

Features

  • Default support for Hashtag, Mention, Link, Phone number and Email
  • Support for custom types via regex
  • Ability to set text color
  • Ability to set pressed state color
  • Ability to make specific modes bold

Download

Gradle:

compile 'com.github.armcha:AutoLinkTextView:0.3.0'

Setup and usage

Add AutoLinkTextView to your layout

    <com.luseen.autolinklibrary.AutoLinkTextView
         android:id="@+id/active"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content" />
AutoLinkTextView autoLinkTextView = (AutoLinkTextView) findViewById(R.id.active);

Set up mode or modes

autoLinkTextView.addAutoLinkMode(
                AutoLinkMode.MODE_PHONE);

Set text to AutoLinkTextView

autoLinkTextView.setAutoLinkText(getString(R.string.long_text));

Set AutoLinkTextView click listener

autoLinkTextView.setAutoLinkOnClickListener(new AutoLinkOnClickListener() {
            @Override
            public void onAutoLinkTextClick(AutoLinkMode autoLinkMode, String matchedText) {

            }
        });

Customizing

AutoLinkModes


AutoLinkMode.MODE_PHONE

AutoLinkMode.MODE_HASHTAG

AutoLinkMode.MODE_URL

AutoLinkMode.MODE_MENTION

AutoLinkMode.MODE_EMAIL

AutoLinkMode.MODE_CUSTOM

if you use custom mode, you should also add custom regex,

autoLinkTextView.setCustomRegex("\\sAllo\\b");

Note:Otherwise MODE_CUSTOM will return MODE_URL

You can also use multiple types

autoLinkTextView.addAutoLinkMode(
                AutoLinkMode.MODE_HASHTAG,
                AutoLinkMode.MODE_PHONE,
                AutoLinkMode.MODE_URL,
                AutoLinkMode.MODE_MENTION,
                AutoLinkMode.MODE_CUSTOM);

You can also change text color for autoLink mode

autoLinkTextView.setHashtagModeColor(ContextCompat.getColor(this, R.color.yourColor));
autoLinkTextView.setPhoneModeColor(ContextCompat.getColor(this, R.color.yourColor));
autoLinkTextView.setCustomModeColor(ContextCompat.getColor(this, R.color.yourColor));
autoLinkTextView.setUrlModeColor(ContextCompat.getColor(this, R.color.yourColor));
autoLinkTextView.setMentionModeColor(ContextCompat.getColor(this, R.color.yourColor));
autoLinkTextView.setEmailModeColor(ContextCompat.getColor(this, R.color.yourColor));

And also autoLink text pressed state color

autoLinkTextView.setSelectedStateColor(ContextCompat.getColor(this, R.color.yourColor));

Set modes that should be bold

autoLinkTextView.setBoldAutoLinkModes(
  AutoLinkMode.MODE_HASHTAG,
  AutoLinkMode.MODE_PHONE,
  AutoLinkMode.MODE_URL,
  AutoLinkMode.MODE_EMAIL,
  AutoLinkMode.MODE_MENTION
);

Enable under line

autoLinkTextView.enableUnderLine();

Contact 📖

▶️ Email: [email protected]

▶️ Medium: https://medium.com/@chatikyan

▶️ Twitter: https://twitter.com/ArmanChatikyan

▶️ Google+: https://plus.google.com/+ArmanChatikyan

▶️ Website: https://armcha.github.io/

License

  Auto Link TextView library for Android
  Copyright (c) 2018 Arman Chatikyan (https://github.com/armcha/AutoLinkTextView).

  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at

     http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.

GitHub

https://github.com/armcha/AutoLinkTextView
Comments
  • 1. [Question] Why made AutoLinkTextView as final class

    I was wondering why you have made AutoLinkTextView as final class which prevent from extending it for further customization. I wanted to extend your view and provide my own implementation for custom fonts.

    For now I have fork your library and made these changes, It would be great if you can remove final in next release.

    Reviewed by aftabsikander at 2016-10-20 08:57
  • 2. AutoLinkTextView in RecyclerView Items

    Hello, @armcha . Firstly, Thank you for your AutoLinkTextView. I used it in my viewholder of recyclerview. But, it never trigger to setAutoLinkOnClickListener event. I already debugged.

    Comment comment=commentList.get(position); commentHolder.txtComment.addAutoLinkMode( AutoLinkMode.MODE_HASHTAG, AutoLinkMode.MODE_PHONE, AutoLinkMode.MODE_URL, AutoLinkMode.MODE_EMAIL, AutoLinkMode.MODE_MENTION); commentHolder.txtComment.setUrlModeColor(ContextCompat.getColor(context, R.color.colorAccent)); commentHolder.txtComment.enableUnderLine(); commentHolder.txtComment.setText(comment.getContent()); commentHolder.txtComment.setAutoLinkOnClickListener(new AutoLinkOnClickListener() { @Override public void onAutoLinkTextClick(AutoLinkMode autoLinkMode, String matchedText) { Toast.makeText(context,autoLinkMode.toString()+" "+matchedText,Toast.LENGTH_SHORT).show(); } });

    Reviewed by Arkar009 at 2019-01-14 08:14
  • 3. NOTHING HAPPEN IN ADAPTER

    I implement this code in adapter, but the color not change

    tvContent = (AutoLinkTextView) itemView.findViewById(R.id.tv_q_content);

            tvContent.addAutoLinkMode(
                    AutoLinkMode.MODE_HASHTAG,
                    AutoLinkMode.MODE_PHONE,
                    AutoLinkMode.MODE_URL,
                    AutoLinkMode.MODE_MENTION,
                    AutoLinkMode.MODE_CUSTOM);
            tvContent.setCustomRegex("\\sAllo\\b");
    
            tvContent.setHashtagModeColor(ContextCompat.getColor(mContext, R.color.instagram));
            tvContent.setPhoneModeColor(ContextCompat.getColor(mContext, R.color.instagram));
            tvContent.setCustomModeColor(ContextCompat.getColor(mContext, R.color.instagram));
            tvContent.setUrlModeColor(ContextCompat.getColor(mContext, R.color.instagram));
            tvContent.setMentionModeColor(ContextCompat.getColor(mContext, R.color.instagram));
            tvContent.setEmailModeColor(ContextCompat.getColor(mContext, R.color.instagram));
            tvContent.setSelectedStateColor(ContextCompat.getColor(mContext, R.color.instagram));
    
    Reviewed by asywalulfikri at 2016-10-03 02:25
  • 4. I tried to use it but it's not changing the text color.

    JAVA

    content.addAutoLinkMode(
                    AutoLinkMode.MODE_HASHTAG,
                    AutoLinkMode.MODE_PHONE,
                    AutoLinkMode.MODE_URL,
                    AutoLinkMode.MODE_EMAIL,
                    AutoLinkMode.MODE_MENTION);
    
            content.setHashtagModeColor(ContextCompat.getColor(this, R.color.colorBlueType1));
            content.setEmailModeColor(ContextCompat.getColor(this, R.color.colorBlueType1));
            content.setMentionModeColor(ContextCompat.getColor(this, R.color.colorBlueType1));
            content.setUrlModeColor(ContextCompat.getColor(this, R.color.colorBlueType1));
    
            content.setText("Enter Content www.gmail.com @the #hkjhs [email protected]");
    

    XML

    <LinearLayout
            android:id="@+id/editPart"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@id/headPart">
    
            <com.luseen.autolinklibrary.AutoLinkTextView
                android:padding="8dp"
                android:id="@+id/body"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:maxLength="280"/>
    
        </LinearLayout>
    

    IMG_20190520_152937 1

    Reviewed by mr0kaushik at 2019-05-20 10:00
  • 5. Missing Import Fix + other minor changes

    • Updated Gradle Build tools from Alpha to Stable.
    • Added missing import for android.text.TextUtils which caused compile error.
    • Removed .idea files from git as they shouldn't be committed.
    • Improved example app dialog by setting AutoLinkMode as the title and matchedText as the message.
    Reviewed by liamcottle at 2017-11-08 09:10
  • 6. Multiple regex for two string

    How can I add two regex: autoLinkTextView.setCustomRegex("\sTerms of Service\b"); autoLinkTextView.setCustomRegex("\sPrivacy Policy\b");

    Reviewed by rvats011990 at 2019-06-25 09:27
  • 7. can i show mention name without showing @

    I need to show mention name without showing @ and also need click event. can you please help me and also wants to know should i set multiple custom AutoLinkMode in single textview?

    Reviewed by khushboojainOffbeat at 2019-01-02 06:14
  • 8. How to bold a certain mode

    Hello i have used your view it is working fine but i want to bold specific view type. how can i implement this as this method not working setBoldAutoLinkModes on latest gradel

    Reviewed by Abhilash1307 at 2018-10-16 11:56
  • 9. crash on fabric

    LinkTouchMovementMethod (Deobfuscated class name) com.luseen.autolinklibrary.LinkTouchMovementMethod.getPressedSpan ( Fatal Exception: java.lang.ArrayIndexOutOfBoundsException length=48; index=48 )

    Reviewed by emad3oon at 2018-09-18 08:39
  • 10. How to handle 2 types of clicks on autolinktextview?

    Hi, i am using this library to display hashtags in listview. working perfectly fine. But i want two types of clicks for AutoLinkTextview.

    1. when clicked on hashtag in AutoLinkTextview - Working perfect
    2. when clicked on AutoLinkTextview (not on Hashtag, side of hashtag) - Need to navigate to detail page. (it's not happening) how to achieve this? Thank you.
    Reviewed by bala-suresh at 2018-06-22 03:21
A TextView that automatically fit its font and line count based on its available size and content
A TextView that automatically fit its font and line count based on its available size and content

AutoFitTextView A TextView that automatically fit its font and line count based on its available size and content This code is heavily based on this S

Jun 15, 2022
A TextView that automatically resizes text to fit perfectly within its bounds.
A TextView that automatically resizes text to fit perfectly within its bounds.

AutoFitTextView A TextView that automatically resizes text to fit perfectly within its bounds. Usage dependencies { compile 'me.grantland:autofitt

Jun 22, 2022
A TextView that changes its content automatically every few seconds
A TextView that changes its content automatically every few seconds

FadingTextView A TextView that changes its content automatically every few seconds Demo app A demo app is available on Google Play: Usage Add this to

Jun 15, 2022
A simple and flexible Checked TextView or Checkable TextView
A simple and flexible Checked TextView or Checkable TextView

CheckableTextView Checkable TextView [KOTLIN] ⚡ A simple and flexible Checked TextView or Checkable TextView written in Kotlin ⚡ What's New Animation

Jun 15, 2022
An all-in-one Jetpack Compose component to handle text styling inside TextFields

An all-in-one Jetpack Compose component to handle text styling inside TextFields

Jun 19, 2022
Form validation and feedback library for Android. Provides .setText for more than just TextView and EditText widgets. Provides easy means to validate with dependencies.
Form validation and feedback library for Android. Provides .setText for more than just TextView and EditText widgets. Provides easy means to validate with dependencies.

android-formidable-validation Form validation and feedback library for Android. Provides .setText for more than just TextView and EditText widgets. Pr

Apr 15, 2021
Implementation of a TextView and all its direct/indirect subclasses with native support for the Roboto fonts, includes the brand new Roboto Slab fonts.
Implementation of a TextView and all its direct/indirect subclasses with native support for the Roboto fonts, includes the brand new Roboto Slab fonts.

Android-RobotoTextView Implementation of a TextView and all its direct/indirect subclasses with native support for the Roboto fonts, includes the bran

Jun 22, 2022
An extension of Android's TextView, EditText and Button that let's you use the font of your choice

AnyTextView (deprecated) Note: AnyTextView is no longer being maintained. I recommend replacing AnyTextView with the Calligraphy library instead. Frus

Mar 17, 2021
Simple way to create linked text, such as @username or #hashtag, in Android TextView and EditText
Simple way to create linked text, such as @username or #hashtag, in Android TextView and EditText

Simple Linkable Text Simple way to create link text, such as @username or #hashtag, in Android TextView and EditText Installation Gradle Add dependenc

Aug 27, 2020
Customized and Expandable TextView
Customized and Expandable TextView

Customized and Expandable TextView Simple library to change the Textview as rectangle, circle and square shapes by adding one line of code in xml file

Apr 7, 2022
Animation effects to text, not really textview
Animation effects to text, not really textview

HTextView Animation effects with custom font support to TextView see iOS Effects see Flutter Effects Screenshot type gif Scale Evaporate Fall Line Typ

Jun 19, 2022
Android's TextView that can expand/collapse like the Google Play's app description

ExpandableTextView ExpandableTextView is an Android library that allows developers to easily create an TextView which can expand/collapse just like th

Jun 20, 2022
A library to show emoji in TextView, EditText (like WhatsApp) for Android
A library to show emoji in TextView, EditText (like WhatsApp) for Android

Discontinued This projected is discontinued. Please consider using other alternative, i.e EmojiCompat. Contact me if you want to continue working on a

Jun 12, 2022
Android experiment showing a sinking TextView
Android experiment showing a sinking TextView

Titanic is an Android experiment reproducing this effect.

Jun 22, 2022
A Custom TextView with trim text
A Custom TextView with trim text

ReadMoreTextView A Custom TextView with trim text Download To add the ReadMoreTextView library to your Android Studio project, simply add the followin

May 30, 2022
Advanced Android TextView

Advanced Android TextView Companion app for my Advanced Android TextView talk, demostrating: Animated CompoundDrawable Text shadow Custom font Non-bre

Jun 16, 2022
A TextView that simulates the effect from the app Secret where the characters fade in/out at different speeds.
A TextView that simulates the effect from the app Secret where the characters fade in/out at different speeds.

SecretTextView A TextView that simulates the effect from the app Secret where the characters fade in/out at different speeds. How To Use Use it just l

Jun 21, 2022
This is based on an open source autosizing textview for Android.

SizeAdjustingTextView This is based on an open source autosizing textview for Android I found a few weeks ago. The initial approach didn't resize mult

Feb 15, 2022
Lightweight android library for highlighting sections of a textview, with optional callbacks.
Lightweight android library for highlighting sections of a textview, with optional callbacks.

Linker Lightweight android library for highlighting Strings inside of a textview (ignoring case), with optional callbacks. Language: Java MinSDK: 17 J

Apr 30, 2022