Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

draw line through text in textview

Tags:

I have started to make an application similar to concept of "To do task manager", in which i need to make a textview cancelable, like, when user clicks on done image, whole text in the view will be cancelled.

Can anyone please guide me on, how to achieve this mechanism ??

like image 560
Chintan Soni Avatar asked Apr 12 '13 11:04

Chintan Soni


People also ask

How to strikethrough in android TextView?

If you want to show a strike-through text you can do it programming using PaintFlags. You can set paint flags Paint. STRIKE_THRU_TEXT_FLAG to a TextView and it will add a strike-through to the text.

How do I add a line under TextView?

A line with the exact space of the TextView will be drawn. Show activity on this post. Insert a divider, on width, start with about 200dp and go from there. Change Background color to what you want, change gravity to center horizontal.


2 Answers

This can help you.

    TextView tv = (TextView) findViewById(R.id.mytext);     tv.setText("This is strike-thru");     tv.setPaintFlags(tv.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG); 

You can use it in your code,however necessary.

like image 98
Josyula Krishna Avatar answered Sep 20 '22 15:09

Josyula Krishna


In Kotlin

tv.text = "This is text" tv.paintFlags = tv.paintFlags or Paint.STRIKE_THRU_TEXT_FLAG 
like image 28
Nux Avatar answered Sep 20 '22 15:09

Nux