I want to have a strike through design before and after of my Text in TextView
----------------------- SETTINGS ---------------------
We can design this through CSS but how to design this type of TEXT in android?
I want to have a strike through design before and after of my Text in TextView
----------------------- SETTINGS ---------------------
We can design this through CSS but how to design this type of TEXT in android?
Try this if you want strike through for the entire TextView.
TextView someTextView = (TextView) findViewById(R.id.some_text_view);
someTextView.setText(someString);
someTextView.setPaintFlags(someTextView.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
If you want only a part of text, or text after and before the actual text to have a strike through try this,
TextView someTextView = (TextView) findViewById(R.id.some_text_view);
someTextView.setText(text, TextView.BufferType.SPANNABLE);
Spannable spannable = (Spannable) someTextView.getText();
spannable.setSpan(new StrikethroughSpan(), 3, text.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
Here text is the text which we want out TextView to display, 3 is the number of characters (starting from 0) from where the strikethrough will start.
See this SO thread.