本文整理匯總了Java中io.plaidapp.util.ViewUtils.getSingleLineTextSize方法的典型用法代碼示例。如果您正苦於以下問題:Java ViewUtils.getSingleLineTextSize方法的具體用法?Java ViewUtils.getSingleLineTextSize怎麽用?Java ViewUtils.getSingleLineTextSize使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類io.plaidapp.util.ViewUtils
的用法示例。
在下文中一共展示了ViewUtils.getSingleLineTextSize方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: calculateTextPosition
import io.plaidapp.util.ViewUtils; //導入方法依賴的package包/類
private void calculateTextPosition() {
float targetWidth = getWidth() / PHI;
textSize = ViewUtils.getSingleLineTextSize(text, textPaint, targetWidth, 0f, maxTextSize,
0.5f, getResources().getDisplayMetrics());
textPaint.setTextSize(textSize);
// measuring text is fun :] see: https://chris.banes.me/2014/03/27/measuring-text/
textX = (getWidth() - textPaint.measureText(text)) / 2;
Rect textBounds = new Rect();
textPaint.getTextBounds(text, 0, text.length(), textBounds);
float textHeight = textBounds.height();
textY = (getHeight() + textHeight) / 2;
}
示例2: calculateTextPosition
import io.plaidapp.util.ViewUtils; //導入方法依賴的package包/類
private void calculateTextPosition() {
float targetWidth = getWidth() / PHI;
float textSize = ViewUtils.getSingleLineTextSize(
text, textPaint, targetWidth, 0f, maxTextSize, 0.5f, getResources().getDisplayMetrics());
textPaint.setTextSize(textSize);
// measuring text is fun :] see: https://chris.banes.me/2014/03/27/measuring-text/
textX = (getWidth() - textPaint.measureText(text)) / 2;
Rect textBounds = new Rect();
textPaint.getTextBounds(text, 0, text.length(), textBounds);
float textHeight = textBounds.height();
textY = (getHeight() + textHeight) / 2;
}