I want to remove extra padding from top and bottom of TextView
. I try setIncludeFontPadding(false);
and also this:
android:layout_marginTop="-Xdp"
android:layout_marginBottom="-Xdp
But they didn't work.
Is there any way to do that?
setIncludeFontPadding
works but it doesn't remove all padding, Specially when you wrap your text view size.
Create a custom TextView
and override onDraw
method then add these lines before calling super
:
@Override
protected void onDraw(Canvas canvas) {
float offset = getTextSize() - getLineHeight();
canvas.translate(0, -offset); //or +offset to moving it to top
super.onDraw(canvas);
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.