TextView划线 android

来源:互联网 发布:淘宝上买的刀怎么开刃 编辑:程序博客网 时间:2024/04/27 15:48

TextView  加下划线 、 中划线

下过如图:

 

// 中划线

textView.getPaint().setFlags(Paint.STRIKE_THRU_TEXT_FLAG | Paint.ANTI_ALIAS_FLAG); // 设置中划线并加清晰

// 下划线

textView.getPaint().setFlags(Paint.UNDERLINE_TEXT_FLAG);


//取消设置的线

textView.getPaint().setFlags(0); // 取消设置的的划线


我封装了几个方法  直接调用

 

/** * 下划线 *  * @param textView */private void addButtomLine(TextView textView) {textView.getPaint().setFlags(Paint.UNDERLINE_TEXT_FLAG);}/** * 移除线 *  * @param textView */private void removeLine(TextView textView) {textView.getPaint().setFlags(0); // 取消设置的的划线}/** * 设置中划线并加清晰 *  * @param textView */private void addLine(TextView textView) {textView.getPaint().setFlags(Paint.STRIKE_THRU_TEXT_FLAG | Paint.ANTI_ALIAS_FLAG); // 设置中划线并加清晰}/** * 中划线 *  * @param textView */private void addCenterLine(TextView textView) {textView.getPaint().setFlags(Paint.STRIKE_THRU_TEXT_FLAG); // 中划线}/** * 抗锯齿 *  * @param textView */private void addjuchiLine(TextView textView) {textView.getPaint().setAntiAlias(true);// 抗锯齿}


 

3 0
原创粉丝点击