singleLine 属性的替代方案(已弃用)TextInputEditText [英] Alternative of singleLine attribute (Deprecated) TextInputEditText

查看:66
本文介绍了singleLine 属性的替代方案(已弃用)TextInputEditText的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近使用了 TextInputEditText,我得到 singleLine 属性 Deprecated

的 lint 错误

有没有其他方法可以解决这个问题?

解决方案

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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆