"The Paint class holds the style and color information about how to draw geometries, text and bitmaps."

  Paint 类实际为 Canvas 提供了填充的样式、画线size、对其方式、是否抗锯齿等属性设置。一般来说,measureText() 是针对于特定字体大小来测量字符串宽度的,否则按默认测量得到的值就不一定有意义了。所以需要添加对待测量字符串字体大小的设置:

Paint paint =new Paint();
paint.setTextSize(currSize);
float strWidth = paint.measureText(myTxt);

相关文章:

  • 2022-12-23
  • 2021-10-03
  • 2021-04-16
  • 2022-12-23
  • 2021-08-24
  • 2022-12-23
  • 2022-12-23
  • 2022-03-09
猜你喜欢
  • 2021-10-18
  • 2022-01-11
  • 2022-02-04
  • 2021-12-24
  • 2022-12-23
  • 2022-12-23
  • 2022-01-14
相关资源
相似解决方案