首页 > 其他 > 详细

获取文本的宽高

时间:2017-08-22 17:15:52      阅读:226      评论:0      收藏:0      [点我收藏+]
/**
     * 获取文本的高度
     * @param text
     * @return
     */
    private int getTextHeight(String text){
        Rect bounds = new Rect();
        mFanPaint.getTextBounds(text,0,text.length(),bounds);
        int height = bounds.bottom + bounds.height();
        return height;
    }

    /**
     * 获取文本的宽度
     * @param text
     * @return
     */
    private int getTextWidth(String text){
        Rect bounds = new Rect();
        mFanPaint.getTextBounds(text,0,text.length(),bounds);
        int width = bounds.left + bounds.width();
        return width;
    }

  

获取文本的宽高

原文:http://www.cnblogs.com/hacjy/p/7412543.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!