Android Based control -- CBAlignTextView

来源:互联网 发布:阿克苏怎样优化网站 编辑:程序博客网 时间:2024/05/20 23:59

我们都十分熟悉TextView的使用,但是还有一个不错的控件CBAlignTextView


使用步骤:

  • build.gradel加入dependencies
    compile ‘me.codeboy.android:align-text-view:2.3.0’
  • xml中

    <me.codeboy.android.aligntextview.CBAlignTextView
    android:id="@+id/cbAlignTv"
    android:textIsSelectable="true"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"/>

特点:

  1. 支持复制
  2. 排版效果较好

注意:

由于Android L(5.0)之后对中文的版本进行了变化,造成不能由中文标点作为行首,所以为了能够使CBAlignTextView看起来更加工整,建议将中文符号用英文符号替换(默认不转换)
解决:
- 使用转化函数转化标点符号:
CBAlignTextViewUtil.replacePunctuation("");
源码:
public static String replacePunctuation(String text) {
text = text.replace(',', ',').replace('。', '.').replace('【', '[').replace('】', ']')
.replace('?', '?').replace('!', '!').replace('(', '(').replace(')', ')').replace
('“', '"').replace('”', '"');
return text;
}

根据自己的需求使用

1 0
原创粉丝点击