我可以在 Android 中创建一个删除线文本吗,我的意思是在 TextView
标记中添加一个特殊值可以实现这一点?
<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"/>
最佳答案
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.
从 Comment 编辑由 Ε Г И І И О :
对于任何想要删除此标志的人,方法如下:
someTextView.setPaintFlags(someTextView.getPaintFlags() & (~Paint.STRIKE_THRU_TEXT_FLAG));
关于android - 创建删除线文本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9786544/