singleLine
is/was used in xml layout files for TextView
and EditText
something like the following:
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="true" />
Some people on SO say singleLine
is deprecated, while other people still suggest using it. Sometimes it even seems necessary to use when maxLines="1"
doesn't work. (see here, here, and here)
The docs should be the place to go to answer this question, right? Here, they say:
This constant was deprecated in API level 3.
This attribute is deprecated. Use
maxLines
instead to change the layout of a static text, and use thetextMultiLine
flag in the inputType attribute instead for editable text views (if both singleLine and inputType are supplied, the inputType flags will override the value of singleLine).
However, in the TextView docs, there is no indication that it is deprecated, either for android:singleLine
or for setSingleLine
or for setTransformationMethod
. The same TextView docs, by comparison, do state that other things like STATUS_BAR_HIDDEN
and fitSystemWindows
are deprecated. So is the singleLine
deprecation an omission, was it "undeprecated", or what?
This question has been previously asked before but was not the main focus of the question (and was not answered).
code
block for both the cases? – Maveňツ May 4 '15 at 11:57maxLines="1"
supposedly doesn't work. (It could be that it really does work in every instance.) I just want to know ifsingleLine
is really deprecated or not. That being said, I don't have any authoritative examples but see theellipsize="marquee"
part of this answer and this Q&A and also this answer with comments. – Suragch May 4 '15 at 12:24TextView
s with it inViewPager
and the pager did not respond to touch slide events, if I slided with finger over thatTextView
s. But when I changed that attribute to maxLines=1, everything went ok! – schmidt9 Jul 23 '16 at 6:07