在文本int TextView中插入水平线

时间:2013-10-18 06:46:10

标签: android textview

enter image description here我在单个TextView中有很多行显示。我从数据库中获取文本然后显示它。所以我想在其中构建包含条目和水平线的数据库。当我复制粘贴它们。只粘贴单词,不出现水平线。我想在线的某些点插入一些水平线,如

您好

<小时/> 嗨,我很好


应该有一个像线一样的分隔线可以插入我想要的地方。有逃脱序列吗?但它应该在TextView文本中完成。 这有什么诀窍吗?我尝试用文字行复制粘贴文本,但它只复制文本而不是行。有没有办法像在html中使用水平标签?任何帮助都非常值得赞赏。

4 个答案:

答案 0 :(得分:1)

尝试以下代码

 <View  android:layout_width="match_parent"
        android:layout_height="0.5dp"
        android:background="@android:color/black"/>

答案 1 :(得分:0)

您可以尝试在TextView中继承一些css:

myTextView.setText(Html.fromHtml("<span style="border....">Hello</span>"));

编辑:

String dynamicText = "textGenerated";
String message = "<span style='border-bottom:1px solid'>" + dynamicText + "</span>";

myTextView.setText(Html.fromHtml(message));

答案 2 :(得分:0)

<?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>

答案 3 :(得分:0)

将以下布局添加到布局XML:

<LinearLayout android:layout_width="match_parent"
    android:layout_height="2dp"
    android:background="@android:color/darker_gray">
</LinearLayout>
相关问题