I want to put a horizontal line within a textview in android studio. I want to create a textview layout like this.
Asked
Active
Viewed 2,762 times
4 Answers
1
You can use this code to get TextView
with a line .
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/tv_textview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Device"
android:layout_centerVertical="true"
android:layout_margin="3dp"
/>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#000"
android:layout_centerVertical="true"
android:layout_toRightOf="@+id/tv_textview"
android:layout_margin="3dp"
/>
</RelativeLayout>
1
- create linear layout with
match_parent
width - set orientation vertical
- put text view child with
wrap_content
width put view with 0dp width and
weight = 1
<View android:layout_width="fill_parent" android:layout_height="1dp" android:background="#000" android:gravity="bottom" />

KeLiuyue
- 8,149
- 4
- 25
- 42

Mostafa Anter
- 3,445
- 24
- 26
0
Do it Programitically Like..
(Use _ for Making a Line)
yourTextView.setText("Device_________________________");
yourTextView.setTextColor("Your Color Here");
and In XML file Set
Android:width = "MatchParent".
for your Text View.
Do this only if you are creating static layout.

Learning Always
- 1,563
- 4
- 29
- 49