Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
769 views
in Technique[技术] by (71.8m points)

android - Alternative of singleLine attribute (Deprecated) TextInputEditText

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:

enter image description here

Is there any alternative way for this?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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 -->

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...