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

Overview

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.
Comments
  • [Question] Why made AutoLinkTextView as final class

    [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.

    opened by aftabsikander 4
  • AutoLinkTextView in RecyclerView Items

    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(); } });

    opened by Arkar009 2
  • NOTHING HAPPEN IN ADAPTER

    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));
    
    opened by asywalulfikri 2
  • I tried to use it but it's not changing the text color.

    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

    opened by mr0kaushik 0
  • Missing Import Fix + other minor changes

    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.
    opened by liamcottle 0
  • Multiple regex for two string

    Multiple regex for two string

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

    opened by rvats011990 0
  • can i show mention name without showing @

    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?

    opened by khushboojainOffbeat 1
  • How to bold a certain mode

    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

    opened by Abhilash1307 2
  • crash on fabric

    crash on fabric

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

    opened by emad3oon 0
  • How to handle 2 types of clicks on autolinktextview?

    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.
    opened by bala-suresh 2
Releases(0.2.0)
Owner
Arman
Arman
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

null 899 Jan 2, 2023
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

Grantland Chew 4.2k Jan 1, 2023
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

Tomer Rosenfeld 1.7k Dec 9, 2022
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

null 110 Nov 20, 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

Paweł Chochura 26 Dec 14, 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.

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

Linden 147 Nov 20, 2022
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

Evgeny Shishkin 782 Nov 12, 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

Hans Petter Eide 165 Nov 11, 2022
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

Aditya Pradana Sugiarto 76 Nov 29, 2022
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

Raja Gopal 62 Sep 22, 2022
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

hanks 5.5k Jan 5, 2023
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

Manabu S. 4k Dec 28, 2022
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

Hieu Rocker 3.6k Jan 5, 2023
Android experiment showing a sinking TextView

Titanic is an Android experiment reproducing this effect.

Romain Piel 1.8k Dec 15, 2022
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

Borja B. 1.7k Dec 29, 2022
Advanced Android TextView

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

Chiu-Ki Chan 1.2k Dec 9, 2022
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

Matt Kula 611 Nov 7, 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

Elliott Chenger 255 Dec 29, 2022
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

Josh Gainey 35 Apr 30, 2022