Android TextView行間隔設定の問題(setLineSpacing,lineSpacingExtra,lineSpacingMultiplier)...
1415 ワード
最近のプロジェクトでは、カスタムコントロールが必要です.ペイントテキストの高さを取得するコンポーネントがあり、TextViewのソースコードを開くと、getLineHeight()という方法があります.
ネット上では、他の方法でテキストの高さを取得する方法もいくつか見つかりました.試験後,上記の方法を用いて,最も正確な高さが得られたことが分かった.テストのコードは貼らない.の
転載先:https://www.cnblogs.com/coolasm/p/3810174.html
public int getLineHeight() {
return FastMath.round(mTextPaint.getFontMetricsInt(null) * mSpacingMult + mSpacingAdd);
}
getLineHeight :
/**
* @return the height of one standard line in pixels. Note that markup
* within the text can cause individual lines to be taller or shorter
* than this height, and the layout may contain additional first-
* or last-line padding.
*/
。 , 。
, 。
FastMath.round( mTextPaint.getFontMetricsInt(null) ) 。
ネット上では、他の方法でテキストの高さを取得する方法もいくつか見つかりました.試験後,上記の方法を用いて,最も正確な高さが得られたことが分かった.テストのコードは貼らない.の
転載先:https://www.cnblogs.com/coolasm/p/3810174.html