在画布上要绘制测量文本高度(安卓)画布、上要、测量、文本

2023-09-12 08:30:33 作者:三生)狂

任何直接的方式来衡量文字的高度? 我现在做的方法是使用涂料的measureText()来获得的宽度,然后通过反复试验找到一个值,以得到一个近似的高度。我也一直在茫然的的FontMetrics,但所有这些看起来像吸吮近似的方法。

Any straight forward way to measure the height of text? The way I am doing it now is by using Paint's measureText() to get the width, then by trial and error finding a value to get an approximate height. I've also been messing around with FontMetrics, but all these seem like approximate methods that suck.

我想扩展事情不同的分辨率。我能做到这一点,但我结束了令人难以置信的详细code,有很多的计算,以确定相对大小。我讨厌它!必须有一个更好的办法。

I am trying to scale things for different resolutions. I can do it, but I end up with incredibly verbose code with lots of calculations to determine relative sizes. I hate it! There has to be a better way.

什么办法,一件事的时间:谢谢

Any way, one thing at a time: Thanks.

推荐答案

什么Paint.getTextBounds()