简体   繁体   中英

Android: EditText hint in single line

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.

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.

Same issue.

Solution:

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

你可以尝试使用

android:maxLines="1"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM