I do have a problem with TextView
. I don\'t want to have any margin/padding above it.
I had the same issue where setting android:includeFontPadding=false
did not help. The best solution I could find in reasonable time was to override the TextView's onDraw
method and to adjust the canvas for the difference between the font metrics' top and ascent values:
FontMetricsInt fontMetricsInt;
@Override
protected void onDraw(Canvas canvas) {
if (adjustTopForAscent){
if (fontMetricsInt == null){
fontMetricsInt = new FontMetricsInt();
getPaint().getFontMetricsInt(fontMetricsInt);
}
canvas.translate(0, fontMetricsInt.top - fontMetricsInt.ascent);
}
super.onDraw(canvas);
}