开发者

EditText with long default text on a single line

开发者 https://www.devze.com 2023-03-22 06:08 出处:网络
I have an EditText that I am trying to set开发者_JAVA百科 with a very long, unbreaking text value (a URL), but even with the following XML declaration, the text is breaking to a second line.

I have an EditText that I am trying to set开发者_JAVA百科 with a very long, unbreaking text value (a URL), but even with the following XML declaration, the text is breaking to a second line.

<EditText 
android:id="@+id/address" 
android:layout_width="wrap_content" 
android:layout_height="match_parent"
android:layout_weight="1"
android:maxLines="1"
android:hint="Enter URL"
android:text="http://www.example.com/news/2010-07-15/this-is-the-story-title-here.html">
</EditText>

I've tried the solutions here (adding android:ellipsize="end"), but it made no difference. Reducing the text in length to something no more than the length of the EditText worked... but this is realistic for a URL EditText.

Any suggestions?

Thanks,

Paul


Set

android:scrollHorizontally="true"


Have you tried adding android:singleLine="true" to the mix

<EditText 
android:id="@+id/address" 
android:layout_width="wrap_content" 
android:layout_height="match_parent"
android:layout_weight="1"
android:singleLine="true"
android:maxLines="1"
android:hint="Enter URL"
android:text="http://www.example.com/news/2010-07-15/this-is-the-story-title-here.html">
</EditText>


Use value for the attribute inputType other than textMultiLine. The attribute singleLine is deprecated.

0

精彩评论

暂无评论...
验证码 换一张
取 消