gpt4 book ai didi

android - 创建删除线文本?

转载 作者:IT老高 更新时间:2023-10-28 13:02:47 24 4
gpt4 key购买 nike

我可以在 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"/>

最佳答案

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.

Comment 编辑由 Ε Г И І И О :

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

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

关于android - 创建删除线文本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9786544/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com