Skip to content

Latest commit

History

4 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

TagEditText,类似微博标签的文本控件

TagEditText实现了显示类似微博中的活动标签, 其特点是将一段文字中用'#'包裹的部分以特殊的颜色显示,并能进行点击交互。

TagEditText

主要功能

  • 自定义包裹符号,如# ... # 或者 * ... *,或者 # ... * ,具体什么符号可以自定义,默认是 # ... #
  • 自定义匹配的标签字体颜色
  • 自定义标签点击事件

使用

  • Gradle : compile 'cn.droidlover:TagEditText:1.0.0''
  • Github : TagEditText

说明

库中主要包括两个控件:

  • TagEditText :主要用于用户评论的编辑,用户可输入类似#...#的内容。
  • TagTextView :主要用于显示内容。

主要用法

TagTextView

 <cn.droidlover.tagedittext.TagTextView
android:id="@+id/tagTextView"android:layout_width="match_parent"android:layout_height="wrap_content"android:padding="16dp"android:textSize="14sp" />

在java中

tagTextView
.tagColor(Color.RED) //设置标签颜色
.tag("#", "#"); //设置前后匹配符tagTextView.setCallback(newTagSpan.Callback<String>() { //设置标签点击事件@OverridepublicvoidonClick(Stringdata) {
toast(data);
}
})
tagTextView.text(str); //设置内容

TagEditText

<cn.droidlover.tagedittext.TagEditText
android:id="@+id/tagEditText"android:layout_width="match_parent"android:hint="TagEditText"android:layout_height="wrap_content"android:layout_marginTop="50dp"android:background="@android:color/transparent"android:padding="16dp"android:textSize="14sp" />

在java中

tagEditText
.tag("#", "#") //设置前后匹配符
.tagColor(Color.BLUE); //设置标签颜色tagEditText.appendText(""); //追加文本tagEditText.getTagList(); //获取标签集合tagEditText.removeText(""); //删除指定

About

Text control for displaying tags.

Resources

Stars

153 stars

Watchers

3 watching

Forks

Releases

Packages

Contributors

Languages