Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typo3/2.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:不要让EditText按空格换行_Android_Android Edittext_Android Xml_Word Wrap - Fatal编程技术网

Android:不要让EditText按空格换行

Android:不要让EditText按空格换行,android,android-edittext,android-xml,word-wrap,Android,Android Edittext,Android Xml,Word Wrap,如果EditText中的文本长度过长,则在文本中添加空格时,空格后的内容将被换行。例如,我有60个1,没有空格或换行符,假设每行可以包含20个1,EditText将显示如下 11111111111111111111 11111111111111111111 11111111111111111111 但是如果我在里面加上空间,它会是这样的 11111111111111111111 1 11111111111111111111 1111111111111111111 我在第二行的第一个1后面添加

如果EditText中的文本长度过长,则在文本中添加空格时,空格后的内容将被换行。例如,我有60个1,没有空格或换行符,假设每行可以包含20个1,EditText将显示如下

11111111111111111111
11111111111111111111
11111111111111111111
但是如果我在里面加上空间,它会是这样的

11111111111111111111
1
11111111111111111111
1111111111111111111
我在第二行的第一个1后面添加了空格,在第二行的第一个1后面添加了其他1。我所期望的是

11111111111111111111
1 111111111111111111
11111111111111111111
1
有什么办法吗

编辑:

我正在尝试编写一个文本编辑器,所以我希望EditText是多行的

我的代码是:

<EditText
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_marginLeft="8dp"
    android:layout_marginTop="4dp"
    android:layout_marginRight="8dp"

    android:inputType="textMultiLine"
    android:gravity="start|top"

    app:layout_constraintTop_toTopOf="parent"
    app:layout_constraintLeft_toLeftOf="parent" />

您在这里想要实现什么?也许您可以将EditText限制为:

  • 作为单线,
    android:singleLine=“true”
  • 限制用户使用很少的行,
    android:maxLines=“1”
  • 使用
    '\n'
你应该看看这个。顺便说一句,请提供更多详细信息,说明您在用户体验和表现方面努力实现的目标。

是。那么:

android:inputType="textMultiLine"
android:singleLine="false"