25

For setting the Single Line in EditText we use android:singleLine="true" but I want to set the single line for the Hint Text, it is large and I want to show it in a one line like:

http://google.myopenid.stackoverflow.com

I am using the following code:

<EditText android:id="@+id/editText1"
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:hint="@string/defaultUrl"
    android:singleLine="true" />

Note: defaultUrl is dynamic and very long URL.

Volo
  • 28,673
  • 12
  • 97
  • 125
Sameer Z.
  • 3,265
  • 9
  • 48
  • 72

3 Answers3

51

You can use

android:ellipsize="end"

android:maxLines="1"

to show your hint text in single line but you wont be able to see the whole text because android:ellipsize="end" truncates the text at the end.

Vikas Patidar
  • 42,865
  • 22
  • 93
  • 106
-1

You can try using

android:maxLines="1"
amiekuser
  • 1,630
  • 1
  • 19
  • 31
  • 1
    I try it already ,it is not working. thanks for you support.If have any other idea or can just tell me how to customize the class. – Sameer Z. Feb 02 '11 at 06:15
-2

Same issue.

Solution:

EditText.setHint("hint content".replace("\n"," "))
4b0
  • 21,981
  • 30
  • 95
  • 142
Xugter
  • 1
  • 1
  • 1
    This does not provide an answer to the question. Once you have sufficient [reputation](https://stackoverflow.com/help/whats-reputation) you will be able to [comment on any post](https://stackoverflow.com/help/privileges/comment) instead, provide [answers that don't require clarification from the asker](https://meta.stackexchange.com/questions/214173/why-do-i-need-50-reputation-to-comment-what-can-i-do-instead) – Agilanbu Nov 23 '18 at 07:24