创建删除线文本? [英] creating a strikethrough text?

查看:78
本文介绍了创建删除线文本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以在Android中创建删除线文本吗,我的意思是在TextView标记中添加一个特殊值以使之成为可能?

Can I create a strikethrough text in Android, I mean adding a special value in the TextView tag that can make this possible?

<TextView
    android:id="@+id/title" 
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" 
    android:textColor="#040404"
    android:typeface="sans" 
    android:textSize="12dip"
    android:textStyle="bold"/>

推荐答案

Paint.STRIKE_THRU_TEXT_FLAG

TextView someTextView = (TextView) findViewById(R.id.some_text_view);
someTextView.setText(someString);
someTextView.setPaintFlags(someTextView.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);

对于绘画文本,有一些用于执行类似操作的位标记 粗体,斜体,并且是删除线.因此,要启用删除线, 您需要翻转与此标志相对应的位.最简单的 做到这一点的方法是在当前标志上使用按位或 对应于一组标志的常量,仅包含 删除线标记已启用.

For painting text, there are several bit flags for doing things like bold, italics, and yes strikethrough. So to enable the strikethrough, you need to flip the bit that corresponds to this flag. The easiest way to do this is to use a bitwise-or on the current flags and a constant that corresponds to a set of flags with only the strikethrough flag enabled.

通过评论中进行编辑. com/users/687190/> EГИІИО:

Edit from Comment by Ε Г И І И О :

对于想要删除此标志的任何人,这是方法:

For any one wanting to remove this flag, this is how:

someTextView.setPaintFlags(someTextView.getPaintFlags() & (~Paint.STRIKE_THRU_TEXT_FLAG));

这篇关于创建删除线文本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆