Reputation: 13199
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!
Upvotes: 8
Views: 1387
Reputation: 4058
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"
Upvotes: 15
Reputation: 6393
You might add the android:singleLine
attribute and set it to false
(it will probably still not work though). However, it seems rather odd to use textMultiLine
and number
together as the new line character is neither a number nor number related.
Also note that the inputType
attribute is merely a hint for the IME and not all of them may honor the set values.
Upvotes: 0