摘要: RecyclerView getChildAdapterPosition(View):获取View在Adapter中的position。 getChildLayoutPosition(View):获取view在layout中的position。注意:大部分情况下,它与getChildAdapterP 阅读全文
posted @ 2020-09-22 15:20 夜行过客 阅读(521) 评论(0) 推荐(0) 编辑
摘要: 1. FontMetrics 计算文本高度: fontMetrics.bottom - fontMetrics.top 2. measureText 通过这个方法即可以轻松的获取到文字的的宽度。比如要获取一个TextView中文本的宽度:textView.getPaint().measureText 阅读全文
posted @ 2020-09-22 14:42 夜行过客 阅读(3388) 评论(0) 推荐(0) 编辑
摘要: 嫌麻烦可以直接看结论: 文本居中的公式: float baseLineY = centerY + (Math.abs(fontMetrics.top) + Math.abs(fontMetrics.bottom)) /2 - fontMetrics.bottom 也可以简化成: float base 阅读全文
posted @ 2020-09-22 11:38 夜行过客 阅读(2209) 评论(0) 推荐(0) 编辑