問題描述
為了在 EditText
中設(shè)置單行,我們使用 android:singleLine="true"
但我想為提示文本設(shè)置單行,它很大而且我想在一行中顯示它:
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
我正在使用以下代碼:
<EditText android:id="@+id/editText1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:hint="@string/defaultUrl"
android:singleLine="true" />
注意:defaultUrl
是動(dòng)態(tài)且很長的 URL.
Note: defaultUrl
is dynamic and very long URL.
推薦答案
可以使用
android:ellipsize="end"
android:maxLines="1"
在單行中顯示您的提示文本,但您將無法看到整個(gè)文本,因?yàn)?code>android:ellipsize="end" 在末尾截?cái)辔谋?
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.
這篇關(guān)于Android:單行中的EditText提示的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!