【Android】 獲取PaintTextHeight方法

public class PaintTextHeightUtils {
	
	public static int getTextHeight(Paint paint) { //前提是先設置文字大小
		Paint.FontMetricsInt fm = paint.getFontMetricsInt();
		int textHeight = ~fm.top - (~fm.top - ~fm.ascent) - (fm.bottom - fm.descent);
		return textHeight;
	}
	// 文字寬度 paint.measureText(text);

}

 

發佈了19 篇原創文章 · 獲贊 22 · 訪問量 8942
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章