this is a screen shot from my android. the text is
You can use .
android:layout_width="fill_parent"
istead of
android:layout_width="wrap_content"
I suspect the issue would not occur if you were not using italic text. I'd test that out first, and if using non-italic text renders it correctly, then it looks like a rendering issue, that would need working around with extra padding in the TextView to allow space for the italic letters.
I encountered the same problem but with EditText
when used some fonts. My solution works also with TextView
:
Use padding
As TextView
using Canvas.clipRect(float, float, float, float)
in onDraw
method to crop - create custom Canvas
class and override this method (leave it empty).
Next сreate custom TextView
and override two methods onSizeChanged
and onDraw
.
In onSizeChanged
create bitmap with the size of TextView
and our custom Canvas
.
In onDraw
first draw in bitmap by passing our custom Canvas
to method super.onDraw. After that draw bitmap to target сanvas.
More detailed in my answer to the similar question here
This is my solution: Format textview and measure. After that set width of textview with 1 pixel add to the width measured.
TextView textView = new TextView(this);
textView.setText("Text blah blah");
textView.setTypeface(typeface, Typeface.BOLD_ITALIC)
textView.measure(MeasureSpec.UNSPECIFIED, MeasureSpec.UNSPECIFIED);
textView.setLayoutParams(new LayoutParams(textView.getMeasuredWidth() + 1, LayoutParams.WRAP_CONTENT));
Working for me. Hope these help.
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.
You could always create custom TextView that will use for example this font (cause in fact this is a problem with italic type):
Typeface tf = Typeface.createFromAsset(context.getAssets(), "fonts/Roboto-LightItalic.ttf");
setTypeface(tf);
More details here.