【发布时间】:2017-05-14 08:03:21
【问题描述】:
我想制作我想在屏幕左侧显示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>
【问题讨论】:
-
如果您决定使用的小部件无法做到这一点,您可以创建自己的(创建一个扩展 APpCOmpatEditText 的新类)或查找库。
-
我只想知道屏幕左侧的行数可以吗??
-
如果你不能用 AppCompatEditText 来做,你必须创建你自己的类来扩展 AppCompatEditText 或者找一个库来做。我不知道你是否可以在其中显示线条,所以这是你必须弄清楚的事情。查找文档,看看是否有任何方法可以显示行号。如果没有创建您自己的版本或查找库
-
就像@LunarWatcher 所说,您需要自己创建一个CustomView,或者为此使用一个库(如果存在)。
标签: android xml android-edittext