Alternative of singleLine attribute (Deprecated) TextInputEditText(singleLine 属性的替代方案(已弃用)TextInputEditText)
问题描述
我最近使用了 TextInputEditText
,我得到 singleLine
属性 Deprecated
有没有其他方法可以解决这个问题?
解决方案 android:singleLine
属性自 API 级别 15.您可以使用 android:maxLines
实现相同的行为,它允许您指定任意数量的行.这优于 android:singleLine
,后者限制您只允许一行.
I recently used TextInputEditText
and I got lint error that singleLine
attribute is Deprecated
<android.support.design.widget.TextInputEditText
android:id="@+id/my_edit_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/string_hint_dob"
android:lines="5"/>
</android.support.design.widget.TextInputLayout>
Getting strike-through as below:
Is there any alternative way for this?
解决方案 The android:singleLine
attribute has been deprecated since API Level 15. You can achieve the same behaviour by using android:maxLines
, which allows you to specify an arbitrary number of lines. This is superior to android:singleLine
, which restricts you to only allowing one line.
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:minLines="2"
android:maxLines="2" /> <!-- can specify arbitrary number of max lines -->
这篇关于singleLine 属性的替代方案(已弃用)TextInputEditText的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:singleLine 属性的替代方案(已弃用)TextInputEditText


- 想使用ViewPager,无法识别android.support.*? 2022-01-01
- android 4中的android RadioButton问题 2022-01-01
- 用 Swift 实现 UITextFieldDelegate 2022-01-01
- 在测试浓缩咖啡时,Android设备不会在屏幕上启动活动 2022-01-01
- Android viewpager检测滑动超出范围 2022-01-01
- 使用自定义动画时在 iOS9 上忽略 edgesForExtendedLayout 2022-01-01
- MalformedJsonException:在第1行第1列路径中使用JsonReader.setLenient(True)接受格式错误的JSON 2022-01-01
- Android - 拆分 Drawable 2022-01-01
- 如何检查发送到 Android 应用程序的 Firebase 消息的传递状态? 2022-01-01
- Android - 我如何找出用户有多少未读电子邮件? 2022-01-01