I use a EditText view with a (Hint : text)
I want to reproduce the (Single line : true) EditText's attribute which is deprecated.
So I use those attributes and values :
(Lines : 1) (Max lines : 1) (Scroll horizontally : true)And it works fine.
But there is a little problem the (Hint : text) attribute is now hidden.Ho开发者_StackOverflow社区w can I bring it back?
Ok here's the thing.
The problem wasn't the inputType "text", it was the Gravity.
When you set the Gravity of a TextView to "Center", the "Hint" disappears.
The way to make it back is to set the Ellipsize to "start".
<EditText
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:hint="Hint"
android:inputType="text"
android:gravity="center"
android:ellipsize="start" />
The only thing you need for single line is android:inputType
attribute.
<EditText
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:hint="Hint"
android:inputType="text" />
精彩评论