1

I am new to Android. I Want to create an TextView like My Image.I search a lot, but I don't get Any Idea. In My TextView how to draw a line on Text. Please help me.

enter image description here

Any Help will be Appreciated.

Ravi
  • 34,851
  • 21
  • 122
  • 183

3 Answers3

2

you can directly create this line in layout file like this

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:orientation="vertical"
android:id="@+id/viewline">

<TextView
    android:id="@+id/txts"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="hello to all"
    android:textColor="#000000"
    android:layout_centerHorizontal="true"
    android:textSize="25sp" />
<View
    android:layout_width="150dp"
    android:layout_height="1dp"
    android:layout_marginTop="15dp"
    android:layout_centerHorizontal="true"
    android:background="#000000"></View>

</RelativeLayout>

which gives a view like:

enter image description here

santoXme
  • 802
  • 5
  • 20
0

try this :

tv.getPaint().setFlags(Paint.STRIKE_THRU_TEXT_FLAG);
S-MILE-S
  • 114
  • 6
-1

For set Strikethrough.

textView.setPaintFlags(txtView.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
textView.setText("10.00 AM");

For clear Strikethrough

textView.setPaintFlags(0);
Chirag Savsani
  • 6,020
  • 4
  • 38
  • 74