Android的单线VS MAXLINES [英] android singleLine vs maxLines
问题描述
我觉得 SINGLELINE =真正的
相当于 MAXLINES =1
,但我看到下面的从Android的工作室pre-填充字段有两种。是否有区别?是否有一个已知的bug,导致既需要?
I thought singleLine="true"
was equivalent to maxLines="1"
but I see that the following pre-populated field from Android Studio has both. Is there a difference? Is there a known bug that causes both to be required?
<EditTextPreference
android:key="example_text"
android:title="@string/pref_title_display_name"
android:defaultValue="@string/pref_default_display_name"
android:selectAllOnFocus="true"
android:inputType="textCapWords"
android:capitalize="words"
android:singleLine="true"
android:maxLines="1" />
这是从 pref_general.xml
文件。
推荐答案
从Android的网站:
From Android website:
singleLine:
约束的文本到单个水平滚动线代替
让它换到多行,和垫款集中,而不是
插入时你preSS回车键换行。缺省值是
假(多线缠绕文本模式)为不可编辑的文本,但是如果你
指定inputType下的任何值,则默认为真(单线
输入场模式)。
Constrains the text to a single horizontally scrolling line instead of letting it wrap onto multiple lines, and advances focus instead of inserting a newline when you press the enter key. The default value is false (multi-line wrapped text mode) for non-editable text, but if you specify any value for inputType, the default is true (single-line input field mode).
必须是一个布尔值,无论是真或假。
Must be a boolean value, either "true" or "false".
MAXLINES :
maxLines:
让TextView的至多这么多线高。当一个使用
可编辑的文本,在inputType下属性的值必须与相结合
对于MAXLINES的textMultiLine标志属性应用。
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.
必须是一个整数值,如100
Must be an integer value, such as "100"
请注意,单线一直以来API 3 MAXLINES应改为使用pcated德$ P $。因此,所有你需要的真的是
Please note that singleLine has been deprecated since API 3 and maxLines should be used instead. So all you need really is
android:maxLines = integer // 1 for single line or add lines multiple as well.
这篇关于Android的单线VS MAXLINES的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!