0

How to Create Drawable on Android look Like text below:

Remove

CinCout
  • 9,486
  • 12
  • 49
  • 67
Ahmad
  • 59
  • 1
  • 7
  • You can draw horizontal line on drawable – Bhoomika Brahmbhatt May 02 '16 at 05:43
  • 1
    Possible duplicate of [draw line through text in textview](http://stackoverflow.com/questions/15970267/draw-line-through-text-in-textview) – Rashid May 02 '16 at 05:49
  • 1
    Possible duplicate of [Is there an easy way to strike through text in an app widget?](http://stackoverflow.com/questions/3881553/is-there-an-easy-way-to-strike-through-text-in-an-app-widget) – Bharatesh May 02 '16 at 06:15
  • Possible duplicate of [how to make text-view exactly like this](http://stackoverflow.com/questions/35348185/how-to-make-text-view-exactly-like-this) – Janki Gadhiya May 02 '16 at 06:43

2 Answers2

1

for single word we can use drawable. Following is the example:

<?xml version="1.0" encoding="utf-8"?>
<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="#ffffff" />
        </shape>
    </item>

</selector>

for multiple line use below:-

TextView tv=(TextView) v.findViewById(android.R.id.text1);
tv.setPaintFlags(tv.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);

use your reference instead of "tv"

0

You can do something like this:

Programatically:

 TextView tv = (TextView) findViewById(R.id.mytext);
    tv.setText("Remove");
    tv.setPaintFlags(tv.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);

From xml file:

    <RelativeLayout
           android:layout_width="wrap_content"
           android:layout_height="wrap_content"
           >
     <TextView
           android:id="@+id/textView2"
           android:layout_width="wrap_content"
           android:layout_height="wrap_content"
           android:text="Remove"
           />
     <View
           android:layout_width="fill_parent"
           android:layout_height="1dp"
           android:background="@color/black"
           android:layout_centerVertical="true"
            />
</RelativeLayout>
Parsania Hardik
  • 4,593
  • 1
  • 33
  • 33