2

Trying to build a shopping cart and want to display discounted price and for old price want to show it as in image

enter image description here

ΦXocę 웃 Пepeúpa ツ
  • 47,427
  • 17
  • 69
  • 97
charan ghumman
  • 469
  • 6
  • 10
  • 3
    See this post I looked up with "android strikethrough" http://stackoverflow.com/questions/3881553/is-there-an-easy-way-to-strike-through-text-in-an-app-widget – Urs Feb 11 '16 at 21:03

2 Answers2

1
textview.getPaint().setFlags(Paint. STRIKE_THRU_TEXT_FLAG|Paint.ANTI_ALIAS_FLAG);  

textView.getPaint().setFlags(0);  //make it gone 
ΦXocę 웃 Пepeúpa ツ
  • 47,427
  • 17
  • 69
  • 97
zkywalker
  • 169
  • 1
  • 7
0

You can use Spannable to achieve this, its more flexible in case you need to put this only in a part of the text. Here is an example:

textview.setText("29,500", TextView.BufferType.SPANNABLE);
final StrikethroughSpan STRIKE_THROUGH_SPAN = new StrikethroughSpan();
Spannable spannable = (Spannable) textview.getText();
spannable.setSpan(STRIKE_THROUGH_SPAN, 0, textview.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
textview.setText(spannable);
JpCrow
  • 4,881
  • 4
  • 32
  • 46