1. 计算宽度
    mPaint.measureText(mProgess);

 

2. 计算高度

    FontMetrics fontMetrics = mPaint.getFontMetrics();
    mTxtHeight = (int) Math.ceil(fontMetrics.descent - fontMetrics.ascent);

 

3. canvas drawText 的x,y值。。 特别注意!

x为坐标值。

y是使用的baseline

android 根据字符串计算宽高

计算y值时,一般是baseY + mTxtHeight - 5(5大概剧中)

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-02-19
  • 2022-12-23
猜你喜欢
  • 2021-05-30
  • 2021-07-10
  • 2022-01-11
  • 2021-11-14
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案