問題描述
我最近使用了 TextInputEditText
,我得到 singleLine
屬性 Deprecated
有沒有其他方法可以解決這個(gè)問題?
解決方案 android:singleLine
屬性自 API 級(jí)別 15.您可以使用 android:maxLines
實(shí)現(xiàn)相同的行為,它允許您指定任意數(shù)量的行.這優(yōu)于 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 -->
這篇關(guān)于singleLine 屬性的替代方案(已棄用)TextInputEditText的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!
【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(lián)系我們刪除處理,感謝您的支持!