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 ?
could be the padding, try setting that to 0dp
also is there anything else in the layout?
To narrow down the source of the error try setting
android:letterSpacing="0"
This was the reason for cut off letters in my case. Another hint for too much letter spacing is that the cut off part get bigger when the text has more letters in it.This is my solution: Format textview and measure. After that set width of textview with 1 pixel add to the width measured.
Working for me. Hope these help.
You could always create custom TextView that will use for example this font (cause in fact this is a problem with italic type):
More details here.
Ok this is pretty strange but I changed from
android:maxLines="1"
toandroid:singleLine="true"
and now the text is not getting cut off.I encountered the same problem but with
EditText
when used some fonts. My solution works also withTextView
:Use padding
As
TextView
usingCanvas.clipRect(float, float, float, float)
inonDraw
method to crop - create customCanvas
class and override this method (leave it empty).Next сreate custom
TextView
and override two methodsonSizeChanged
andonDraw
.In
onSizeChanged
create bitmap with the size ofTextView
and our customCanvas
.In
onDraw
first draw in bitmap by passing our customCanvas
to method super.onDraw. After that draw bitmap to target сanvas.More detailed in my answer to the similar question here