tags:

views:

116

answers:

3

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 is it impossible to have anything overflow from the screen?

For example, you have this:

text being wrapped

But you really want this:

text being cropped

Any ideas?

A: 

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

BrennaSoft
+2  A: 

check out android:singleLine="true" 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:singleLine="true"
            android:ellipsize="end"
/>
Pentium10
@Pentium10: Nice, thanks. How would this be done for buttons and stuff though?
jay
Huh. Probably the same way. There is not much you can do about them beyond what I just showed. You use the height and width stuff to limit the view, and the rest will be cut off.
Pentium10
+1  A: 

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

LucaB