inputType =“数字".多于一行 [英] inputType="number" with more than one line
问题描述
我有以下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=""/>
rounded_corners
所在的位置:
<?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>
问题是因为当我添加 inputType="number"
时,我不知道该怎么做EditText
更大(仅显示一行) .我的意思是它可能显示多于一行.
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.
我尝试过的事情
1).将layout_height
更改为match_parent
.
2)将textMultiLine
值添加到inputType
属性.
3)用android:height
设置固定高度.
4)如您在上面的代码中所见,我还添加了android:minLines
属性.
4) As you can see in the code above, I also add android:minLines
attribute.
5),我还尝试使用android:lines
设置许多行.
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.
提前谢谢!
推荐答案
请将这两行添加到您的EditText XML文件中,它将起作用:
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"
这篇关于inputType =“数字".多于一行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!