自定义View中如何获得文本的宽和高

来源:互联网 发布:聊天软件市场分析 编辑:程序博客网 时间:2024/05/22 16:59

文本的真实宽和高,可以通过如下方法来获取:

        Rect rect = new Rect();        mPaint.getTextBounds(str,0,str.length(),rect);        int height = rect.height();        int width = rect.width();



原创粉丝点击