Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

inputType="number" with more than one line

I have the following EditText:

<EditText
     android:id="@+id/txt1"
     android:layout_width="match_parent"
     android:layout_height="wrap_content"
     android:layout_gravity="center"
     android:layout_marginLeft="20dp"
     android:layout_marginRight="20dp"
     android:layout_marginTop="15dp"
     android:background="@drawable/rounded_corners"
     android:hint="Txt1"
     android:inputType="number"
     android:minLines="2"
     android:text=""/>

where rounded_corners it's:

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >

    <stroke
        android:width="1dp"
        android:color="#FFFFFFFF" />

    <solid android:color="#FFFFFFFF" />

    <padding
        android:left="1dp"
        android:right="1dp"
        android:top="1dp" />

    <corners android:radius="5dp"/>

</shape>

The problem it's that I don't know how to do this EditText bigger (it just display one line) when I add inputType="number". I mean that it could have more than one line displayed.

What I have tried

1) Change the layout_height to match_parent.

2) Add to the inputType attribute the value textMultiLine.

3) Set a fixed height with android:height.

4) As you can see in the code above, I also add android:minLines attribute.

5) I also tried setting a number of lines with android:lines.

None of this methods solve my problem so any help would be really appreciated.

Thanks in advance!

like image 349
Francisco Romero Avatar asked Aug 23 '15 04:08

Francisco Romero


Video Answer


1 Answers

Please add these two lines to your EditText XML file, it works:

android:inputType="textMultiLine|number"

android:digits="0,1,2,3,4,5,6,7,8,9"
like image 117
Awadesh Avatar answered Sep 29 '22 21:09

Awadesh