Multi line Edit Text and first letter capitalization of Edit Text

旧时模样 提交于 2020-02-21 10:05:11

问题


Hello I am trying to make EditText to multi line and first letter should be type as in capital which I am doing using android:inputType="textCapSentences" but after setting to input type to textCapSentences it set first letter in capital but EditText is single line only. Can you please help me to make EditText to multiline plus first letter should be type in capital

Here it is current EditText

<EditText
    android:id="@+id/commentsEditText"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginTop="@dimen/view_vertical_margin"
    android:background="@android:drawable/editbox_background"
    android:inputType="textCapSentences"
    android:gravity="top"
    android:hint="@string/comments"
    android:lines="5" />

回答1:


Have you try below code :-

<EditText
    android:id="@+id/commentsEditText"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@android:drawable/editbox_background"
    android:inputType="textCapSentences|textMultiLine"
    android:gravity="top"
    android:hint="@string/comments"
    android:lines="5" />



回答2:


Try to set EditText input type as below :

android:inputType="textCapSentences|textMultiLine"



回答3:


<EditText
        android:id="@+id/commentsEditText"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="@dimen/view_vertical_margin"
        android:background="@android:drawable/editbox_background"
        android:inputType="textCapSentences"
        android:gravity="top"
        android:hint="@string/comments"
        android:lines="5"
        android:singleLine="false" />



回答4:


use edittext.setRawInputType(InputType.TYPE_TEXT_FLAG_CAP_SENTENCES);

and in xml android:inputType="textMultiLine"



来源:https://stackoverflow.com/questions/23651166/multi-line-edit-text-and-first-letter-capitalization-of-edit-text

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!