根据字符串的长度得到其在屏幕上的px值
2016-03-21 18:38
218 查看
/** * 根据字符串的长度得到其在屏幕上的px值 * * @param textView * @param nameFormat * @param start * @param end * @return */ private int getPxByTextLength(TextView textView, String nameFormat, int start, int end) { if (nameWidthList == null) { nameWidthList = new ArrayList<>(); } Rect bounds = new Rect(); TextPaint paint = textView.getPaint(); paint.getTextBounds(nameFormat, start, end, bounds); final int width = bounds.width(); System.out.println("parseText width = " + width); nameWidthList.add(width); return width; }
相关文章推荐
- iOS的layout机制相关方法
- Hive的UDF实现及注意事项
- Android RecyclerView 使用完全解析 体验艺术般的控件
- mysql中的字符串的拼接
- theano版logistic
- HDU1372搜索
- osgi3——camel配置restlet
- HDU1372搜索
- 用Reveal分析第三方App的UI
- iOS平台下运用百度地图SDK(swift语言)
- acm 1008同1001木桩题
- POJ-3984-迷宫问题【经典BFS】
- 并查集python实现
- 杂文_压行神技
- Jetty加载solr-5.1.0 并且添加mmseg4j分词器
- [LeetCode]-DataBase-Nth Highest Salary
- Android官方开发文档Training系列课程中文版:构建第一款安卓应用之创建用户界面
- JAVA反射详解
- OpenCV实现基于8*8块DCT变换的图像压缩
- java 使用queue