Android:EditText - 多行和android:inputType

时间:2013-07-02 19:05:27

标签: android android-edittext newline

我对EditText有一个(?简单?)问题。每当我输入它时,即使我到达屏幕边缘而不是创建新行,文本也会保持在同一行。我确定我之前默认这样做,但我似乎无法让它工作知道......

<EditText
        android:id="@+id/title"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:hint="@string/hint"
        android:inputType="textCapSentences" />
编辑:问题是因为有一个android:inputType。有没有办法让输入类型有多行?

1 个答案:

答案 0 :(得分:31)

您可以通过使用管道“|”分隔标志来在输入类型上设置多个属性字符。尝试以下设置:

android:inputType="textCapSentences|textMultiLine"

完整代码:

<EditText
    android:id="@+id/title"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:hint="@string/hint"
    android:lines="3"
    android:inputType="textCapSentences|textMultiLine" />