Remove space between stacked TextViews
Try using negative margins. It may take a bit of playing with the numbers to get it right, but I've done it before and it worked out well.
android:layout_marginTop="-5dp"
Make baseline of the text equal to the bottom of the TextView.
public class BaselineTextView extends TextView {
public BaselineTextView(Context context, AttributeSet attrs) {
super(context, attrs);
}
@Override
protected void onDraw(Canvas canvas) {
int yOffset = getHeight() - getBaseline();
canvas.translate(0, yOffset);
super.onDraw(canvas);
}
}
NOTE: To avoid chopping off descenders call setClipChildren(false)
on your TextView
's parent ViewGroup
(android:clipChildren="false"
in XML).
By default, a TextView includes some padding to leave space for accent characters. You can turn that off with:
android:includeFontPadding="false"
or
textView.setIncludeFontPadding(false)