Waqas Ahmed Waqas Ahmed - 1 year ago 85
Java Question

creating a horizontal line over a textview in android

i am making a math tutor for school kids... In it's Subtraction lesson, I want to make a horizontal line over a textview while taking a borrow from a number.
Look at the image below. The line created on Textview.How it can be done programaticaly.. just like this.

Answer Source
textView.setPaintFlags(textView.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG); 

To change hight of textView strike create drawable file strike.xml

<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="false"><shape android:shape="line">
    <stroke android:width="2dp" android:color="#000000" />

in your xml set textview background