我是靠谱客的博主 怡然红酒,这篇文章主要介绍Android: 在 TextView 里使用删除线,现在分享给大家,希望可以做个参考。

以编程的方式添给 TextView 添加删除线:

textview.getPaint().setFlags(Paint.STRIKE_THRU_TEXT_FLAG);

顺便研究下:

TextView.getPaint() :

// Returns the base paint used for the text.
// Please use this only to consult the Paint's properties and not to change them.
public TextPaint getPaint();

TextPaint:

// TextPaint is an extension of Paint that leaves room 
// for some extra data used during text measuring and drawing.
public class TextPaint extends Paint {...}

Paint:

// The Paint class holds the style and color information
// about how to draw geometries, text and bitmaps.
public class Paint extends Object {...}

Paint.setFlags():

// Set the paint's flags. Use the Flag enum to specific flag values.
// flags: The new flag bits for the paint
public void setFlags (int flags);

Paint.STRIKE_THRU_TEXT_FLAG:

// Paint flag that applies a strike-through decoration to drawn text.
// Constant Value: 16 (0x00000010)
public static final int STRIKE_THRU_TEXT_FLAG;

参考资料:

  • TextView | Android Developers http://developer.android.com/reference/android/widget/TextView.html
  • TextPaint | Android Developers http://developer.android.com/reference/android/text/TextPaint.html
  • Paint | Android Developers http://developer.android.com/reference/android/graphics/Paint.html

最后

以上就是怡然红酒最近收集整理的关于Android: 在 TextView 里使用删除线的全部内容,更多相关Android:内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(109)

评论列表共有 0 条评论

立即
投稿
返回
顶部