All Projects → jaychang0917 → Simpletext

jaychang0917 / Simpletext

Licence: apache-2.0
A simple spannable string helper

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Simpletext

unicode-formatter
Convert portions of text to fancy text using unicode fonts for use on Twitter and other sites that don't support rich text
Stars: ✭ 31 (-94.11%)
Mutual labels:  rich-text
html2any
🌀 parse and convert html string to anything
Stars: ✭ 43 (-91.83%)
Mutual labels:  rich-text
Angular Editor
A simple native WYSIWYG editor component for Angular 6 -10+
Stars: ✭ 428 (-18.63%)
Mutual labels:  rich-text
textbus
Textbus 是一个组件化的、数据驱动的富文本框架,支持在线协同编辑,同时也可以作为一个开箱即用的富文本编辑器,拥有非常好的扩展性和可定制性,是构建复杂富文本的不二之选!
Stars: ✭ 642 (+22.05%)
Mutual labels:  rich-text
unity-rich-text
🌈 Forget about rich text tags pain
Stars: ✭ 14 (-97.34%)
Mutual labels:  rich-text
Text
📑 Collaborative document editing using Markdown
Stars: ✭ 282 (-46.39%)
Mutual labels:  rich-text
v-editor
📝Write md or rich text easily
Stars: ✭ 22 (-95.82%)
Mutual labels:  rich-text
Dante
A sane rich text parsing and styling library.
Stars: ✭ 450 (-14.45%)
Mutual labels:  rich-text
richvariables
DEPRECATED Allows you to easily use Craft Globals as variables in Rich Text fields
Stars: ✭ 44 (-91.63%)
Mutual labels:  rich-text
Hricheditor
Android端富文本编辑器HEichEditor
Stars: ✭ 311 (-40.87%)
Mutual labels:  rich-text
rich-text
A set of companion packages for GraphCMS's Rich Text Field
Stars: ✭ 62 (-88.21%)
Mutual labels:  rich-text
storyblok-rich-text-react-renderer
A React renderer for Storyblok rich text content
Stars: ✭ 33 (-93.73%)
Mutual labels:  rich-text
Spedittool
An efficient and scalable library for inputing and displaying gif or @mention on graph-text mixed TextView/EditText
Stars: ✭ 292 (-44.49%)
Mutual labels:  rich-text
mobility-actiontext
Translate Rails Action Text rich text with Mobility.
Stars: ✭ 27 (-94.87%)
Mutual labels:  rich-text
Slate
A completely customizable framework for building rich text editors. (Currently in beta.)
Stars: ✭ 23,104 (+4292.4%)
Mutual labels:  rich-text
we-rich
HTML转微信富文本节点, we just need rich, no text.
Stars: ✭ 36 (-93.16%)
Mutual labels:  rich-text
richTextParse
微信小程序富文本解析(仅支持HTML),在rich-text标签引用结果“树”
Stars: ✭ 53 (-89.92%)
Mutual labels:  rich-text
Element Tiptap
🌸A modern WYSIWYG rich-text editor using tiptap and Element UI for Vue.js
Stars: ✭ 481 (-8.56%)
Mutual labels:  rich-text
Nudein
An easy-to-use attributed text view for iOS Apps,use like masonry
Stars: ✭ 450 (-14.45%)
Mutual labels:  rich-text
Attributedstring
基于Swift插值方式优雅的构建富文本, 支持点击长按事件, 支持不同类型过滤, 支持自定义视图等.
Stars: ✭ 294 (-44.11%)
Mutual labels:  rich-text

SimpleText

Download

This libary aims to simplify the creation of spannable string.

Features

  • [x] long click event
  • [x] bind an object with the clicked text
  • [x] click event (with pressed color state)
  • [x] text background (with round corner)
  • [x] text color
  • [x] text size
  • [x] text style (bold, italic)
  • [x] url
  • [x] text font
  • [x] strikethrough
  • [x] underline
  • [x] subscript
  • [x] superscript

Installation

In your app level build.gradle :

dependencies {
    compile 'com.jaychang:simpletext:2.0.1'
}

Download

Usage

Step 1: Match your target text(s)

Method Description
first(text) match first occurrence
last(text) match last occurrence
all(text) match all occurrences
all() match whole text
allStartWith(prefixs...) match all occurrences with specified prefix(s)
range(from:to) match text at specified position
ranges(ranges) match all texts at specified positions
between(startText:endText) match text between two texts

Step 2: Apply style(s)

Example

TextView textView = (TextView) findViewById(R.id.textView);

String text = "This is a simple #foo @bar text \n SimpleText";
String url = "https://github.com/jaychang0917/SimpleText";

User foo = new User("1001", "foo");
User bar = new User("1002", "bar");

SimpleText simpleText = SimpleText.from(text)
  .allStartWith("#", "@")
  .tags(foo, bar)
  .textColor(R.color.link)
  .pressedTextColor(R.color.pressedText)
  .pressedBackground(R.color.pressedBg, 2) // 2 is corner radius in dp
  .onClick(textView, new OnTextClickListener() {
    @Override
    public void onClicked(CharSequence text, Range range, Object tag) {
      Toast.makeText(MainActivity.this, tag.toString(), Toast.LENGTH_SHORT).show();
    }
  })
  
  .first("simple")
  .textColor(R.color.colorAccent)
  
  .first("SimpleText")
  .bold()
  .textColor(R.color.link)
  .url(url)
  .onLongClick(textView, new OnTextLongClickListener() {
    @Override
    public void onLongClicked(CharSequence text, Range range, Object tag) {
      Toast.makeText(MainActivity.this, "[long click] to share " + tag.toString(), Toast.LENGTH_SHORT).show();
    }
  });

textView.setText(simpleText);

Change Log

Change Log

License

Copyright 2016 Jay Chang

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.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].