我想制作文字编辑器,我希望在屏幕左侧显示number of lines
写的
就像在这张图片中一样,在编辑文本中写的行数如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>
答案 0 :(得分:0)
我看到你正在使用EditText视图,所以在这里你可以找到一个教程,如何创建一个自定义的EditText,你将在其中包含行号:
https://mahbubzaman.wordpress.com/2015/05/11/custom-edittext-with-line-number/
我希望它会对你有所帮助:)。