Android 在文本编辑器中显示行数
我想做一个文本编辑器,我想在其中显示屏幕左侧显示的行数 如图所示,编辑文本中的行数如1、2、3等 我还想当用户向上或向下滚动的行数也滚动。提前感谢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
<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说,如果没有创建自己的版本或找到类库,你需要创建自己的自定义视图,或者使用库(如果存在的话)。