Let’s look at two pictures

code

    /** * Calculates the distance from the baseline to the central axis when drawing text **@param p
    * @param centerY
    * @returnDistance between baseline and centerY */
   public static float getBaseline(Paint p) {
       FontMetrics fontMetrics = p.getFontMetrics();
       return (fontMetrics.descent - fontMetrics.ascent) / 2 -fontMetrics.descent;
   }
Copy the code

Reference links] [www.jianshu.com/p/057ce6b81…