Android maxLines和minLines属性不适用于XML

Android maxLines和minLines属性不适用于XML,第1张

概述我有一个XML文件,其中包含具有以下属性的EditText:<EditTextandroid:id="@+id/et_firstname"android:layout_width="match_parent"android:layout_height="wrap_content"android:layout_marginBottom="@dimen/vie

我有一个XML文件,其中包含具有以下属性的EditText:

<EditText        androID:ID="@+ID/et_firstname"        androID:layout_wIDth="match_parent"        androID:layout_height="wrap_content"        androID:layout_marginBottom="@dimen/vIEw_margin_below"        androID:hint="@string/et_firstname"        androID:maxLength="20"        androID:minlines="1"        androID:maxlines="1" />

由于androID:singleline已被弃用,我寻找另一个选项,我找到了这些属性,但它们无法正常工作.我被允许输入尽可能多的换行符.

解决方法:

就像在minlines和maxlines属性的API中所描述的那样,你必须使用属性androID:inputType =“textMultiline”:

API:

androID:maxlines

Makes the TextVIEw be at most this many lines tall.
When used on an editable text, the inputType attribute’s value must be
combined with the textMultiline flag for the maxlines attribute to
apply.

androID:minlines

Makes the TextVIEw be at least this many lines tall. When used on an
editable text, the inputType attribute’s value must be combined with
the textMultiline flag for the minlines attribute to apply.

<EditText        androID:ID="@+ID/et_firstname"        androID:layout_wIDth="match_parent"        androID:layout_height="wrap_content"        androID:layout_marginBottom="@dimen/vIEw_margin_below"        androID:hint="@string/et_firstname"        androID:maxLength="20"        androID:minlines="1"        androID:inputType="textMultiline"        androID:maxlines="1" />

所以我想,你只需要添加这个属性.

编辑

为了避免误解:这些属性的行为将允许输入多行,但它只会显示一行.但是,它是可滚动的,所以如果你输入更多的行,你可以向上和向下滚动以查看其他行.

这在单线程的API中说明. minlines和maxlines的工作方式类似:

Constrains the text to a single horizontally scrolling line instead of
letting it wrap onto multiple lines

总结

以上是内存溢出为你收集整理的Android maxLines和minLines属性不适用于XML全部内容,希望文章能够帮你解决Android maxLines和minLines属性不适用于XML所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/1111350.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-29
下一篇2022-05-29

发表评论

登录后才能评论

评论列表(0条)

    保存