导航
导航

TextView垂直方向位置Span

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
public class VerticalAlignmentSpan extends MetricAffectingSpan {
double ratio = 0.5;

public VerticalAlignmentSpan() {
}

public VerticalAlignmentSpan(double ratio) {
this.ratio = ratio;
}

@Override
public void updateDrawState(TextPaint paint) {
paint.baselineShift += (int) (paint.ascent() * ratio);
}

@Override
public void updateMeasureState(TextPaint paint) {
paint.baselineShift += (int) (paint.ascent() * ratio);
}
}

转载请指明出处RobinBlog:http://robinx.net/2018/08/30/TextView垂直方向位置Span/