android drawText()使用小记
来源:互联网 发布:数据库锁的原理 编辑:程序博客网 时间:2024/04/29 09:16
1.对于drawText()的使用网上有很多说明,多次使用后总结如下: //确定文字绘制区域 Rect targetRect = new Rect(0, (int) ((2*r)-ImageTop-ModeTextSize), getWidth(), (int)((2*r)-ImageTop)); mPaint.setColor(Color.RED);//需要在<span style="font-family: Arial, Helvetica, sans-serif;">mPaint.getFontMetricsInt();之前设置设置字体大小或者默认大小 mPaint.setTextSize(ModeTextSize); mPaint.setColor(Color.WHITE); Paint.FontMetricsInt fontMetrics = mPaint.getFontMetricsInt();//部分网上资料这里使用的是fontMetrics.bottom,发现总是偏下,但使用bottom好像是合理的,不知道具体是什么原因,猜想可能谷歌给的上部分空白空间给特殊语种的,或者拼音标注什么的,待查 int baseline = (targetRect.bottom + targetRect.top - fontMetrics.ascent + fontMetrics.descent) / 2- fontMetrics.bottom; mPaint.setTextAlign(Paint.Align.CENTER); canvas.drawText(TxMode, targetRect.centerX(), baseline, mPaint);
0 0
- android drawText()使用小记
- Android 自定义View中drawText位置注意事项小记
- android drawText
- android drawText
- Android-drawText
- 如何“任性”使用Android的drawText()
- 如何“任性”使用Android的drawText()
- 如何“任性”使用Android的drawText()
- 如何“任性”使用Android的drawText()
- Android Paint drawText使用完全解读
- 如何“任性”使用Android的drawText()
- android Intent 使用 小记
- android gradient 使用小记
- Android Studio使用小记
- Android paint的drawText() 的正确使用方式
- Android画图drawText 技巧
- android canvas drawText 使用说明
- Android drawText 纵向居中
- 2015年中国十大公有云服务企业综述
- iOS深入学习(使用CocoaPods进行第三方资源管理)
- ActiveMQ简单的HelloWorld实例
- android 获取联系人(姓名,手机号)
- Ajax 基本知识
- android drawText()使用小记
- Activity的四种launchMode
- IOS学习笔记之UIToolBar
- Hibernate4 一个baseDao的封装,包含一些通用的增删改查方法
- 网易云音乐歌单的推荐算法
- You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version
- Bringing up interface eth0: Error: No suitable device found: no device found for connection 'System
- Android Studio下JNI编程(引入外部或AS自行编译so文件)
- Android M版本设置数据主卡的流程