Reputation: 1376
I have a plenty of lines to display in a single TextView . I get the text from database and then display it. So I want to build the database with entries and horizontal lines in it. When I copy paste them. Only words get pasted and horizontal lines don't appear. I want to insert some horizontal lines at some points of the line like
Hello
There should be a divider like line that can be inserted at places I want . Are there any escape sequences? But it should be done in TextView text. Is there any trick to do it? I tried copy pasting the text with line from word but it only copies the text and not the line . Are there any ways to do it like using the horizontal tag in html?? Any help is highly appreciable..
Upvotes: 2
Views: 3080
Reputation: 1611
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:id="@+id/editText1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="hello" >
</TextView>
<LinearLayout android:layout_width="match_parent"
android:layout_height="2dp"
android:background="@android:color/darker_gray"
android:padding="5dp">
</LinearLayout>
<TextView
android:id="@+id/editText1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="hi I am Fine" >
</TextView>
<LinearLayout android:layout_width="match_parent"
android:layout_height="2dp"
android:background="@android:color/darker_gray"
android:padding="5dp">
</LinearLayout>
</LinearLayout>
Upvotes: 0
Reputation: 5145
Add this layout below to your layout XML:
<LinearLayout android:layout_width="match_parent"
android:layout_height="2dp"
android:background="@android:color/darker_gray">
</LinearLayout>
Upvotes: 0
Reputation: 5506
You could try to do some css inherited in the TextView:
myTextView.setText(Html.fromHtml("<span style="border....">Hello</span>"));
Edit:
String dynamicText = "textGenerated";
String message = "<span style='border-bottom:1px solid'>" + dynamicText + "</span>";
myTextView.setText(Html.fromHtml(message));
Upvotes: 0
Reputation: 21929
try below code
<View android:layout_width="match_parent"
android:layout_height="0.5dp"
android:background="@android:color/black"/>
Upvotes: 1