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.

3
  • so you wan tht hint url should be displayed at only as one line? Commented Feb 2, 2011 at 5:52
  • 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? Commented Feb 2, 2011 at 5:54
  • I am trying to show only the small url and then append like google.com/... Commented Feb 2, 2011 at 6:17

3 Answers 3

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.

Sign up to request clarification or add additional context in comments.

Comments

-1

You can try using

android:maxLines="1"

1 Comment

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

Same issue.

Solution:

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

1 Comment

This does not provide an answer to the question. Once you have sufficient reputation you will be able to comment on any post instead, provide answers that don't require clarification from the asker

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.