Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/223.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
Java EditText与textMultiLine不工作_Java_Android_Android Edittext_Textview_Multiline - Fatal编程技术网

Java EditText与textMultiLine不工作

Java EditText与textMultiLine不工作,java,android,android-edittext,textview,multiline,Java,Android,Android Edittext,Textview,Multiline,这是我的编辑文本。为什么不允许多行 <EditText android:id="@+id/edtextDesigner" android:layout_width="250dp" android:layout_height="wrap_content" android:layout_below="@+id/toggleText" android:layout_centerHorizontal="true" android:layout_mar

这是我的编辑文本。为什么不允许多行

<EditText
    android:id="@+id/edtextDesigner"
    android:layout_width="250dp"
    android:layout_height="wrap_content"
    android:layout_below="@+id/toggleText"
    android:layout_centerHorizontal="true"
    android:layout_marginTop="20dp"
    android:alpha="0.5"
    android:background="@drawable/rounded_corner"
    android:ems="10"
    android:lines="2"
    android:focusable="true"
    android:focusableInTouchMode="true"
    android:fontFamily="sans-serif-light"
    android:inputType="textMultiLine"
    android:padding="10dp"
    android:scrollHorizontally="false"
    android:textColor="#000000"
    android:textSize="16sp"
    android:typeface="sans"
    android:text=" "
    android:visibility="invisible" />

我完全不知道为什么这不起作用。

我最近遇到了这个问题。我发现设置inputType程序会重置大多数选项,因此您必须在之后设置它们。我认为将您的代码更改为此可能有效:

edit_View.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_MULTI_LINE);
edit_View.setSingleLine(false);
edit_View.setImeOptions(EditorInfo.IME_FLAG_NO_ENTER_ACTION);

我最近有这个问题。我发现设置inputType程序会重置大多数选项,因此您必须在之后设置它们。我认为将您的代码更改为此可能有效:

edit_View.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_MULTI_LINE);
edit_View.setSingleLine(false);
edit_View.setImeOptions(EditorInfo.IME_FLAG_NO_ENTER_ACTION);
这就是成功的原因:

<EditText
        android:maxLines="4"
        android:lines="4"
        android:gravity="top"
        android:singleLine="false"
        android:maxLength="255"
        android:id="@+id/etRemarks"
        android:layout_width="match_parent"
        android:inputType="textMultiLine|textCapSentences"
        android:layout_height="wrap_content"
        android:importantForAutofill="no" />
这就是成功的原因:

<EditText
        android:maxLines="4"
        android:lines="4"
        android:gravity="top"
        android:singleLine="false"
        android:maxLength="255"
        android:id="@+id/etRemarks"
        android:layout_width="match_parent"
        android:inputType="textMultiLine|textCapSentences"
        android:layout_height="wrap_content"
        android:importantForAutofill="no" />

我不明白。默认情况下,所有
EditText
s都是多行的。请尝试删除行:2和背景i删除
edit\u View.setImeOptions(EditorInfo.IME\u FLAG\u NO\u ENTER\u ACTION)而且似乎有效。我不明白。默认情况下,所有
EditText
s都是多行的。请尝试删除行:2和背景i删除
edit\u View.setImeOptions(EditorInfo.IME\u FLAG\u NO\u ENTER\u ACTION)并且它似乎起作用了。