https://github.com/tylersuehr7/social-text-view
A custom Android TextView that highlights social media lingo (#hashtags, @mentions, phone, emails, and urls).
https://github.com/tylersuehr7/social-text-view
android android-textview hashtag media mention social social-media text text-view view
Last synced: about 1 year ago
JSON representation
A custom Android TextView that highlights social media lingo (#hashtags, @mentions, phone, emails, and urls).
- Host: GitHub
- URL: https://github.com/tylersuehr7/social-text-view
- Owner: tylersuehr7
- License: mit
- Created: 2017-01-22T01:59:00.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2018-12-20T03:51:25.000Z (over 7 years ago)
- Last Synced: 2025-03-30T12:05:10.297Z (about 1 year ago)
- Topics: android, android-textview, hashtag, media, mention, social, social-media, text, text-view, view
- Language: Java
- Homepage:
- Size: 1.22 MB
- Stars: 75
- Watchers: 4
- Forks: 11
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Social Text View
A custom Android TextView that highlights social media lingo (#hashtags, @mentions, phone, emails, and urls).

Core features of this library:
* Highlight social media lingo in text
* Clickable social media lingo in text
How to use it...
In your project level build.gradle :
```java
allprojects {
repositories {
...
maven { url "https://jitpack.io" }
}
}
```
In your app level build.gradle:
```java
dependencies {
compile 'com.github.tylersuehr7:social-text-view:1.0.0'
}
```
## Using the Social Text View
The basic usage of this library is to highlight, and make clickable, whenever social media lingo appears in text. To achieve this functionality, you'll need to use the `SocialTextView`.
This library also includes an object, `AccurateMovementMethod`, which improves the touch on the Android `LinkMovementMethod`, so that clicking links are much more accurate.
### Using in an XML layout
`SocialTextView` can be used in any ViewGroup and supports all available width and height attributes that `TextView` does. Simple usage is shown here:
```xml
```
Here is a table of all the XML attributes available for this view:
Attribute | Type | Summary
:---: | :---: | ---
`app:hashtagColor` | `color` | Sets the text color of a hashtag link in the text.
`app:mentionColor` | `color` | Sets the text color of a mention link in the text.
`app:phoneColor` | `color` | Sets the text color of a phone number link in the text.
`app:emailColor` | `color` | Sets the text color of an email link in the text.
`app:urlColor` | `color` | Sets the text color of a web url link in the text.
`app:selectedColor` | `color` | Sets the text color of a selected link in the text.
`app:linkModes` | `int` | Sets flags for which types of links the text should show. i.e: "hashtag|mention|email|phone|url".
### Using in Java code
`SocialTextView` can be programmatically added into any ViewGroup. Simple usage in an Activity is shown here:
```java
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Text to display in the view
String example = "Really neat stuff @tylersuehr7! #Android #GitHub";
// Create an instance of the view and set the text above
SocialTextView textView = new SocialTextView(this);
textView.setLinkText(example);
// set any other properties you want social text view
setContentView(textView);
}
```
Here is a table of all the accessible attributes available for this view:
Method | Summary
--- | ---
`setLinkText(String)` | Checks the given text for any available links and displays it.
`appendLinkText(String)` | Checks the given text for any available links and appends it.
`setOnLinkClickListener(OnLinkClickListener)` | Sets a listener for when available links are clicked.