Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

textview cutting off a letter in android

Tags:

android

http://dl.dropbox.com/u/24856/Screenshots/android/cutoff.png

this is a screen shot from my android. the text is "asd". however the "d" is slightly cut off. here is the relevant view:

        <TextView
            android:id="@+id/stuff"
            android:padding="2dp"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:layout_below="@+id/other_stuff"
            android:layout_marginTop="33dp"
            android:textAppearance="?android:attr/textAppearanceLarge"
            android:textStyle="italic" />

any idea as to what is causing this ?

like image 764
tipu Avatar asked Apr 20 '12 09:04

tipu


People also ask

How do I cut text on android?

Android: How to Cut, Copy, and Paste TextTap and hold your finger on the text box you are copying text from for about 2 seconds until a menu appears at the top of the screen and the text becomes highlighted. Drag the selection to highlight the exact text you wish to work with. Select the “Cut” or “Copy” icon option.

How do I limit characters in TextView?

you can extend the TextView class and overwrite the setText() function. In this function you check for text length or word cound. Better than counting the text length or the word cound a better way would be to use the "maxLines" attribute along with "ellipsize" attribute to attain the desired effect.

How do I Auto Resize TextView?

To use preset sizes to set up the autosizing of TextView in XML, use the android namespace and set the following attributes: Set the autoSizeText attribute to either none or uniform. none is a default value and uniform lets TextView scale uniformly on horizontal and vertical axes.


4 Answers

ended up with a hacky solution which is adding a white space after the last italicized character

like image 158
tipu Avatar answered Oct 17 '22 18:10

tipu


Ok this is pretty strange but I changed from android:maxLines="1" to android:singleLine="true" and now the text is not getting cut off.

like image 36
Etienne Lawlor Avatar answered Oct 17 '22 17:10

Etienne Lawlor


This is caused by Android setting the TextView clipping rectangle for standard text and you using italic text. Italic text leans to the right, outside of the text bounds. For some reason Android does not account for this.

To prevent this, you can force a TextView to draw outside of its bounds by giving it a text shadow. If you set the shadow color to transparent, the result is simply un-clipped text. Add these to your TextView:

android:shadowColor="#00FFFFFF"
android:shadowDx="48"
android:shadowDy="0"
android:shadowRadius="1"

Also, if this doesn't work, try setting android:clipChildren=false on the parent layout.

like image 5
Michael P Avatar answered Oct 17 '22 17:10

Michael P


I fixed it with setting the width of TextView to fill_parent instead of wrap_content...

like image 4
Div S Avatar answered Oct 17 '22 17:10

Div S