25
votes

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.

3
so you wan tht hint url should be displayed at only as one line? - chikka.anddev
you are using this long Hint Text in one line and does it make any sense when user won't be able to read all at once? - Vikas Patidar
I am trying to show only the small url and then append like google.com/... - Sameer Z.

3 Answers

52
votes

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.

-1
votes

You can try using

android:maxLines="1"
-2
votes

Same issue.

Solution:

EditText.setHint("hint content".replace("\n"," "))