简体   繁体   中英

Display only single line at a time, in a Multiline Edittext

I have tried android:singleLine, maxLines, lineSpacing attributes but my EditText always displays a part of next line. How can I force it to display a single line at a time?

<EditText
    android:layout_width="match_parent"
    android:layout_height="30dp"
    android:id="@+id/formulaView"
    android:textColor="#000000"
    android:textCursorDrawable="@drawable/visible_cursor"
    android:background="#ffffff"
    android:layout_marginTop="1dp"
    android:textSize="18sp"
    android:maxHeight="30dp"
    android:gravity="center_vertical"
    android:layout_marginBottom="1dp"
    android:paddingStart="10dp"
    android:paddingEnd="10dp"
    android:scrollbars="vertical"
    android:imeOptions="actionNext"
    android:completionThreshold="1"
    android:inputType="textMultiLine|textNoSuggestions"/>

在此处输入图片说明

Don't Use

android:inputType="textMultiLine|textNoSuggestions"

Instead use:

android:inputType="textNoSuggestions" 

Code:

<EditText
        android:layout_width="match_parent"
        android:layout_height="30dp"
        android:id="@+id/formulaView"
        android:textColor="#000000"
        android:background="#ffffff"
        android:layout_marginTop="1dp"
        android:textSize="18sp"
        android:text="=SUM(android,Hello,How,Are,You) GoodMorining"
        android:maxHeight="30dp"
        android:gravity="center_vertical"
        android:layout_marginBottom="1dp"
        android:paddingStart="10dp"
        android:paddingEnd="10dp"
        android:scrollbars="vertical"
        android:imeOptions="actionNext"
        android:completionThreshold="1"
        android:singleLine="true"
        android:inputType="textNoSuggestions"/>

Hope this will help.

Have a great day ahead.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM