Android Based control -- CBAlignTextView

我们都十分熟悉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
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值