Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 在文本编辑器中显示行数_Android_Xml_Android Edittext - Fatal编程技术网

Android 在文本编辑器中显示行数

Android 在文本编辑器中显示行数,android,xml,android-edittext,Android,Xml,Android Edittext,我想做一个文本编辑器,我想在其中显示屏幕左侧显示的行数 如图所示,编辑文本中的行数如1、2、3等 我还想当用户向上或向下滚动的行数也滚动。提前感谢 <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/to

我想做一个文本编辑器,我想在其中显示屏幕左侧显示的行数

如图所示,编辑文本中的行数如1、2、3等

我还想当用户向上或向下滚动的行数也滚动。提前感谢

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.osama.cryptofmroot.extras.TextEditorActivity">


    <android.support.v7.widget.AppCompatEditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="@string/type_here"
        android:inputType="textMultiLine"
        android:paddingLeft="16dp"
        android:paddingRight="16dp"
        android:paddingTop="16dp"
        android:paddingBottom="16dp"
        android:id="@+id/editor_area"
        android:backgroundTint="@android:color/transparent"
        />

    </ScrollView>

正如我看到的,您正在使用EditText视图,因此在这里您可以找到一个教程,介绍如何创建自定义EditText,其中包括行号:


我希望它能帮助您:

如果您决定使用的小部件无法做到这一点,您可以创建自己的类,创建一个扩展AppCompatiEditText的新类,或者查找一个库。我只想知道屏幕左侧的行数是否可能??如果无法使用AppCompatiEditText执行此操作,则必须创建自己的扩展AppCompatiEditText的类,或者查找一个库来执行此操作。我不知道你是否能在里面显示线条,所以这是你必须弄清楚的。查找文档,查看是否有任何方法显示行号。@LunarWatcher说,如果没有创建自己的版本或找到类库,你需要创建自己的自定义视图,或者使用库(如果存在的话)。