开发者

Prevent TextView from wrapping in parent

How do I prevent a TextView, or any visual object, from wrapping to the screen and instead have them chopped off the sides? Is there some XML attribute or code to do this or 开发者_如何学Pythonis it impossible to have anything overflow from the screen?

For example, you have this:

Prevent TextView from wrapping in parent

But you really want this:

Prevent TextView from wrapping in parent

Any ideas?


check out android:maxLines="1" and if you want to add ending ... add also android:ellipsize="end"

<TextView
   android:id="@+id/name"
   android:text="i want this to crop not wrap"
   android:layout_width="fill_parent"
   android:layout_height="wrap_content"
   android:maxLines="1"
   android:ellipsize="end" />

android:singleLine="true" was deprecated in API Level 3.


You're looking for android:singleLine="true".


Have you checked out android:scrollHorizontally. There is also a HorizontalScrollView if that doesn't work.


And in java code it's:

textView.setSingleLine();


textView.setHorizontallyScrolling(true); worked for me.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜