Comments (2)
@willBars
FontMetrics.top的数值是个负数,其绝对值就是字体绘制边界到baseline的距离。
所以如果是把文字画在 FontMetrics高度的矩形中, drawText就应该传入 -FontMetrics.top。
要画在targetRect的居中位置,baseline的计算公式就是:
targetRect.centerY() - (FontMetrics.bottom - FontMetrics.top) / 2 - FontMetrics.top
优化后即:
(targetRect.bottom + targetRect.top - fontMetrics.bottom - fontMetrics.top) / 2
给你个链接看看相关介绍 链接
from androidcustomview.
@willBars 今天提供了一种新的思路处理,你可以看下源码哦
from androidcustomview.
Related Issues (16)
- 刚测试一个问题 HOT 7
- mark
- 吸顶效果bug HOT 2
- 仿微信密码输入框,需要考虑边框的线宽 HOT 1
- 大佬,遇到一个问题,顶部的外框线没了 HOT 2
- HorizontalProgressBar问题 HOT 4
- 密码输入框禁止复制粘贴怎么处理呢 HOT 1
- progressBar自定义不能拖动吗
- fir 的二维码挂了 HOT 1
- 矩形变圆角和两圆向中靠拢是同时进行的。 HOT 2
- TextView实现打印机效果的问题 HOT 1
- 自定义进度条 HOT 1
- textview打印机。 HOT 1
- setSpanSizeLookup方法没有调用是什么鬼 HOT 1
- 自定义密码框有个bug HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from androidcustomview.