is it possible multiline with input type as number in Android Edittext?

后端 未结 2 1978
一向
一向 2021-01-06 01:00

When the android edittext input type is number, is it possible to make multilines? I have tried with the following in xml file.

android:inputType=\"number|textMultiL

相关标签:
2条回答
  • 2021-01-06 01:03

    I tried each and every solution for your problem.The thing is that when you try to use android:inputType attribute with number android doesnot provide textMultiLine feature for users.it is possible with only one attribute i.e., android:numeric="integer".I know that it is Deprecated but for your problem this is the only solution.

    I have made a sample xml file.it is as follows:

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical" >
    
        <EditText
            android:id="@+id/editText2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:ems="10"
            android:gravity="top"
            android:lines="10"
            android:numeric="integer" />
    
        <EditText
            android:id="@+id/editText3"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:ems="10"
            android:maxLines="10"
            android:numeric="integer" />
    
        <EditText
            android:id="@+id/editText4"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:ems="10"
            android:maxLines="10"
            android:numeric="integer" />
    
    </LinearLayout>
    

    There are sample EditText used with explanation as follows:-

    The first one describes the TextView be exactly this many lines tall by using the attribute-android:lines="10".Here if you donot provide android:gravity="top" then any input you do will start from the center of the EditText.

    The second one describes the TextView be at most this many lines tall by using the attribute-android:maxLines="10".

    I hope you will finally be happy for your problem being solved successfully.

    0 讨论(0)
  • 2021-01-06 01:13

    Please do this:

    android:inputType="textMultiLine|number"
    android:digits="0,1,2,3,4,5,6,7,8,9"
    

    Taken from here: Answer

    0 讨论(0)
提交回复
热议问题