查询了google发现在android一下有几种方法可以做到,但是经过实际测试发现下面这种方法是最准确的


Rect bounds = new Rect();String text = "Hello World";TextPaint paint;paint = findViewById(R.id.hello_world).getPaint();paint.getTextBounds(text, 0, text.length(), bounds);int width = bounds.width();



更多相关文章

  1. 启动android后没有应用图标,找不到应用程序
  2. Mac 搭建Android开发环境
  3. Android之系统自带的文字外观设置及实际显示效果图
  4. Android(安卓)4.0: 旋转屏幕时禁止Activity重新加载
  5. RecyclerView设置addItemDecoration在Fragment中不显示
  6. Android(安卓)保存图片到相册无法显示的问题
  7. 浅析 Android(安卓)生命周期(一)
  8. Android多核与单核的性能持平的问题
  9. android画经过多点的曲线

随机推荐

  1. Android架构组件_LiveData
  2. MediaPlayer的错误列表速查(android)
  3. 蓝牙通讯开发记录
  4. Android(安卓)SQLite Database
  5. Android(安卓)DOC翻译—Processes and Th
  6. adb tools
  7. android.graphics.Paint类详解
  8. Android开源项目分类汇总
  9. Java中HashMap如何工作的?
  10. android 管理wifi