gpt4 book ai didi

android singleLine vs maxLines

转载 作者:IT老高 更新时间:2023-10-28 22:14:59 25 4
gpt4 key购买 nike

我认为 singleLine="true" 等同于 maxLines="1" 但我看到 Android Studio 中的以下预填充字段两者都有。有区别吗?是否存在导致两者都需要的已知错误?

<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 文件。

最佳答案

来自安卓网站:

singleLine :

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 :

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.

Must be an integer value, such as "100"

请注意,自 API 3 以来,singleLine 已被弃用,而应使用 maxLines。所以你真正需要的是

android:maxLines = integer // 1 for single line or add lines multiple as well.

关于android singleLine vs maxLines,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30879471/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com