3

我想做一个编辑笔记并在其背景中画一条纸线。如下图所示(如您所见,无论是垂直线还是水平线):

在此处输入图像描述

我不知道如何绘制它,如何重复它?

4

1 回答 1

4

这是您问题的答案https://stackoverflow.com/a/10770670/619673

当然,您可以在 textview 中实现它(链接的主题是关于 edittext)但它是完全相同的操作(我认为 :D )。要在您的 xml 中使用它,您必须编写TextView自定义小部件类的包路径而不是包路径,即com.example.notepad.linkededit

在此处输入图像描述

例子:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity" >

    <com.example.notepadline.LinedEditText
        android:id="@+id/tv"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:singleLine="false"
        android:text="AAAA AAAA AAA AAAA AAAA AAA AAAA AAAA AAA AAAA AAAA AAA AAAA AAAA AAA AAAA AAAA AAA" />

</RelativeLayout>

其余信息在参考链接中。

于 2013-06-16T09:56:18.777 回答