设置android:TextInputItemText上的行不工作
当使用设置android:TextInputItemText上的行不工作,android,android-layout,text,multiline,android-textinputedittext,Android,Android Layout,Text,Multiline,Android Textinputedittext,当使用textinputtext和TextInputLayout时,是否有人知道如何在显示前显示总行数?当使用普通的EditText而不使用TextInputLayout时,我没有这个问题。这是我的示例代码: <android.support.design.widget.TextInputLayout android:id="@+id/input_layout" android:layout_width="match_pare
textinputtext
和TextInputLayout
时,是否有人知道如何在显示前显示总行数?当使用普通的EditText而不使用TextInputLayout
时,我没有这个问题。这是我的示例代码:
<android.support.design.widget.TextInputLayout
android:id="@+id/input_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/spacing_small"
app:counterEnabled="true"
app:counterMaxLength="1000"
app:counterOverflowTextAppearance="@style/TextLimitError"
app:hintTextAppearance="@style/TextAppearance.App.TextInputLayout"
app:theme="@style/TextInputLayoutStyle">
<android.support.design.widget.TextInputEditText
android:id="@+id/input"
style="@style/TextInputEditTextStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="hint text"
android:inputType="textMultiLine"
android:lines="5"
android:maxLength="1000"/>
</android.support.design.widget.TextInputLayout>
这是我在设置textinputtext
上的android:lines
时得到的结果。它在浮动标签和我键入的第一个字母之间留下了一个空白
试试下面的android:gravity=“top | left”
这可能会有所帮助
<android.support.design.widget.TextInputLayout
android:id="@+id/input_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/spacing_small"
app:counterEnabled="true"
app:counterMaxLength="1000"
app:counterOverflowTextAppearance="@style/TextLimitError"
app:hintTextAppearance="@style/TextAppearance.App.TextInputLayout"
app:theme="@style/TextInputLayoutStyle">
<EditText
android:id="@+id/input"
style="@style/TextInputEditTextStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="top|left"
android:hint="hint text"
android:inputType="textMultiLine"
android:lines="3"
android:maxLines="5"
android:minLines="3"
android:maxLength="1000"
android:singleLine="false"
android:scrollbars="vertical"/>
</android.support.design.widget.TextInputLayout>
设置android:gravity=“top | left”正在工作,如下所示:
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.design.widget.TextInputEditText
android:id="@+id/notesValue"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="left|top"
android:hint="@string/mlNote"
android:inputType="textCapSentences|textMultiLine"
android:lines="3" />
</android.support.design.widget.TextInputLayout>
Tryandroid:maxLines
@ADM它不工作textinputtext
最终是EditText
的子代。它应该会起作用。可能罪魁祸首是android:maxLength
。那么android:minLines
呢?你能告诉我确切的错误吗?这对我也有效,但我必须指定android:lines
,并在那里提供一个固定的数字。你知道如何让它接受可变数量的行,最好是包装文本吗?@Dambakk你是说提供动态行数。。。。。如果是,那么试着通过编程设置行。是的,这很好,但是当用户输入更多文本时呢?文本应该换行,但不能换行。你知道为什么或者如何实现这种行为吗?哦,我只需要设置isSingleLine=false
。尴尬……)ohh lol:)很高兴能帮助你,并将根据你的建议更新我的代码。。。