- mongodb - 在 MongoDB mapreduce 中,如何展平值对象?
- javascript - 对象传播与 Object.assign
- html - 输入类型 ="submit"Vs 按钮标签它们可以互换吗?
- sql - 使用 MongoDB 而不是 MS SQL Server 的优缺点
我认为 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
文件。
最佳答案
来自安卓网站:
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/
我有一个按钮: public class MyButton extends Button{ private float degrees; public MyButton(C
这是我的 AutoCompleteTextView 代码。 问题是我想输入一些文本,然后点击软键盘上的Next。 Next 出现在软键盘上,但它没有将光标移动到下一个 EditText。在同一个屏幕
我有一个 TextView,它位于屏幕左侧,设置为重力 =“right”,它设置为 SingleLine = “true”。 如果这个 View 中的文本变得太长,我希望它从 View 的左侧消失。我
我想将 edittext 条目限制为单行,但是当我添加行 android:singleline = "true" 时,提示消失,输入 26 个字符后光标向下. 这是我的 XML 代码: 最佳答
我认为 singleLine="true" 等同于 maxLines="1" 但我看到 Android Studio 中的以下预填充字段两者都有。有区别吗?是否存在导致两者都需要的已知错误? 这是来
我正在尝试匹配文件的某个结尾,其中“文件的某个结尾”可能会跨越多行。 我的正则表达式如下所示: "\s\w$" 我想要做的:查找所有以空格字符结尾的文件,并在文件的最末尾加上“人类可读字符”。 Reg
我正在尝试让一个 TextView 采用多行并按父级的大小进行切割。 这并不强制它只是这个 View 的宽度。文本离开屏幕。 TextView 只有在我给它一个像素数
我的风格如下 @dimen/text_size_penny @color/color_default true 后来我有了另一种风格,除了不是单行外,其他都是一样的。所以我
我如何动态地启用和禁用 android:singleLine?我有一个 ListView ,我想在 listView 中使用文本 singleLine true 和一些 sinleLine false
我最近使用了 TextInputEditText,我得到 singleLine 属性 Deprecated 的 lint 错误 删除线如下: 有没有其他方法可以解决这个问题? 最佳答案 andro
只有当 EditText 具有焦点时,我才需要将一个 EditText 限制在 1 行,但当它具有焦点时它什么也不做,只有当它具有焦点并且我关闭应用程序时才有效。我不知道为什么会这样,我尝试了一些方法
我使用以下样式来布局按钮: wrap_content wrap_content true web 按钮本身嵌套在一些 LinearLayouts 中,这些 Line
我有一个 TextView,我想知道它是否由于 XML 中的 singleLine="true"而被截断。 有什么想法可以实现这一点而无需传递显示的文本,而仅使用 TextView 检测它? 最佳答案
我遇到了 android:ellipsize 的问题,它在 TextView 中不起作用。但要适用于 android:singleLine。 我听说 android:singleLine 已被“弃用”
我需要为我的 edittext 设置 actiondone 而不设置单行选项(我需要多行输入)。我该怎么做? 这是代码: 最佳答案 这对我有用: 关于android - 没有 singl
singleLine 是/曾在 TextView 和 EditText 的 xml 布局文件中使用,如下所示: Some people在 SO 上说 singleLine 已弃用,而 other p
找不到更改 TextField 的光标位置并使其成为单行的方法。有人找到办法吗? 这个时候我用的是最新的jetpack-compose 1.0.0-alpha03版本。 最佳答案 要设置光标,您需要像
我有以下 AutoCompleteTextView : 此 AutoCompleteTextView 的输入是通过我创建的“拨号器”布局完成的,因此此 AutoCompleteTextVi
我有一个自定义 TextView,它的 onDraw 方法被覆盖以在 TextView 周围绘制红色边框。 当我将重力设置为左侧以外的其他值时 AND singleLine=true :不绘制边框。
我注意到android:singleLine="true"如果用在ListView中Listitem的TextView中,会导致滚动很卡顿。虽然我找到了替代的 android:maxLines="1"
我是一名优秀的程序员,十分优秀!