本文整理汇总了Java中android.text.StaticLayout.getLineBottom方法的典型用法代码示例。如果您正苦于以下问题:Java StaticLayout.getLineBottom方法的具体用法?Java StaticLayout.getLineBottom怎么用?Java StaticLayout.getLineBottom使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.text.StaticLayout
的用法示例。
在下文中一共展示了StaticLayout.getLineBottom方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setTitle
import android.text.StaticLayout; //导入方法依赖的package包/类
public void setTitle(String title) {
stringBuilder.setLength(0);
if (title != null && title.length() > 0) {
stringBuilder.append(title.substring(0, 1));
}
if (stringBuilder.length() > 0) {
String text = stringBuilder.toString().toUpperCase();
try {
textLayout = new StaticLayout(text, namePaint, AndroidUtilities.dp(100), Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false);
if (textLayout.getLineCount() > 0) {
textLeft = textLayout.getLineLeft(0);
textWidth = textLayout.getLineWidth(0);
textHeight = textLayout.getLineBottom(0);
}
} catch (Exception e) {
FileLog.e("tmessages", e);
}
} else {
textLayout = null;
}
}
示例2: getHeightS
import android.text.StaticLayout; //导入方法依赖的package包/类
private int getHeightS() {
TextPaint textPaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG);
textPaint.setTextSize(getTextSize());
StaticLayout staticLayout = new StaticLayout(textList.get(currentPosition), textPaint, getWidth() - getPaddingLeft() - getPaddingRight(), Layout.Alignment.ALIGN_NORMAL, 1.0f, 0, false);
int height = staticLayout.getHeight();
if (staticLayout.getLineCount() > getMaxLines()) {
int lineCount = staticLayout.getLineCount();
height = staticLayout.getLineBottom(getMaxLines() - 1);
}
return height;
}
示例3: drawTextLayout
import android.text.StaticLayout; //导入方法依赖的package包/类
private void drawTextLayout(Canvas canvas) {
StaticLayout layout = textLayout;
if (layout == null) {
// Nothing to draw.
return;
}
int saveCount = canvas.save();
canvas.translate(textLeft, textTop);
if (Color.alpha(windowColor) > 0) {
paint.setColor(windowColor);
canvas.drawRect(-textPaddingX, 0, layout.getWidth() + textPaddingX, layout.getHeight(),
paint);
}
if (Color.alpha(backgroundColor) > 0) {
paint.setColor(backgroundColor);
float previousBottom = layout.getLineTop(0);
int lineCount = layout.getLineCount();
for (int i = 0; i < lineCount; i++) {
lineBounds.left = layout.getLineLeft(i) - textPaddingX;
lineBounds.right = layout.getLineRight(i) + textPaddingX;
lineBounds.top = previousBottom;
lineBounds.bottom = layout.getLineBottom(i);
previousBottom = lineBounds.bottom;
canvas.drawRoundRect(lineBounds, cornerRadius, cornerRadius, paint);
}
}
if (edgeType == CaptionStyleCompat.EDGE_TYPE_OUTLINE) {
textPaint.setStrokeJoin(Join.ROUND);
textPaint.setStrokeWidth(outlineWidth);
textPaint.setColor(edgeColor);
textPaint.setStyle(Style.FILL_AND_STROKE);
layout.draw(canvas);
} else if (edgeType == CaptionStyleCompat.EDGE_TYPE_DROP_SHADOW) {
textPaint.setShadowLayer(shadowRadius, shadowOffset, shadowOffset, edgeColor);
} else if (edgeType == CaptionStyleCompat.EDGE_TYPE_RAISED
|| edgeType == CaptionStyleCompat.EDGE_TYPE_DEPRESSED) {
boolean raised = edgeType == CaptionStyleCompat.EDGE_TYPE_RAISED;
int colorUp = raised ? Color.WHITE : edgeColor;
int colorDown = raised ? edgeColor : Color.WHITE;
float offset = shadowRadius / 2f;
textPaint.setColor(foregroundColor);
textPaint.setStyle(Style.FILL);
textPaint.setShadowLayer(shadowRadius, -offset, -offset, colorUp);
layout.draw(canvas);
textPaint.setShadowLayer(shadowRadius, offset, offset, colorDown);
}
textPaint.setColor(foregroundColor);
textPaint.setStyle(Style.FILL);
layout.draw(canvas);
textPaint.setShadowLayer(0, 0, 0, 0);
canvas.restoreToCount(saveCount);
}
示例4: onDraw
import android.text.StaticLayout; //导入方法依赖的package包/类
@Override
protected void onDraw(Canvas canvas) {
if (titleLayout != null) {
canvas.save();
canvas.translate(AndroidUtilities.dp(LocaleController.isRTL ? 8 : AndroidUtilities.leftBaseline), titleY);
titleLayout.draw(canvas);
canvas.restore();
}
if (descriptionLayout != null) {
descriptionTextPaint.setColor(0xff212121);
canvas.save();
canvas.translate(AndroidUtilities.dp(LocaleController.isRTL ? 8 : AndroidUtilities.leftBaseline), descriptionY);
descriptionLayout.draw(canvas);
canvas.restore();
}
if (descriptionLayout2 != null) {
descriptionTextPaint.setColor(0xff212121);
canvas.save();
canvas.translate(AndroidUtilities.dp(LocaleController.isRTL ? 8 : AndroidUtilities.leftBaseline), description2Y);
descriptionLayout2.draw(canvas);
canvas.restore();
}
if (!linkLayout.isEmpty()) {
descriptionTextPaint.setColor(Theme.MSG_LINK_TEXT_COLOR);
int offset = 0;
for (int a = 0; a < linkLayout.size(); a++) {
StaticLayout layout = linkLayout.get(a);
if (layout.getLineCount() > 0) {
canvas.save();
canvas.translate(AndroidUtilities.dp(LocaleController.isRTL ? 8 : AndroidUtilities.leftBaseline), linkY + offset);
if (pressedLink == a) {
canvas.drawPath(urlPath, urlPaint);
}
layout.draw(canvas);
canvas.restore();
offset += layout.getLineBottom(layout.getLineCount() - 1);
}
}
}
letterDrawable.draw(canvas);
if (drawLinkImageView) {
linkImageView.draw(canvas);
}
if (needDivider) {
if (LocaleController.isRTL) {
canvas.drawLine(0, getMeasuredHeight() - 1, getMeasuredWidth() - AndroidUtilities.dp(AndroidUtilities.leftBaseline), getMeasuredHeight() - 1, paint);
} else {
canvas.drawLine(AndroidUtilities.dp(AndroidUtilities.leftBaseline), getMeasuredHeight() - 1, getMeasuredWidth(), getMeasuredHeight() - 1, paint);
}
}
}
示例5: setInfo
import android.text.StaticLayout; //导入方法依赖的package包/类
public void setInfo(int id, String firstName, String lastName, boolean isBroadcast) {
if (isProfile) {
color = arrColorsProfiles[getColorIndex(id)];
} else {
color = arrColors[getColorIndex(id)];
}
drawBrodcast = isBroadcast;
if (firstName == null || firstName.length() == 0) {
firstName = lastName;
lastName = null;
}
stringBuilder.setLength(0);
if (firstName != null && firstName.length() > 0) {
stringBuilder.append(firstName.substring(0, 1));
}
if (lastName != null && lastName.length() > 0) {
String lastch = null;
for (int a = lastName.length() - 1; a >= 0; a--) {
if (lastch != null && lastName.charAt(a) == ' ') {
break;
}
lastch = lastName.substring(a, a + 1);
}
if (Build.VERSION.SDK_INT >= 16) {
stringBuilder.append("\u200C");
}
stringBuilder.append(lastch);
} else if (firstName != null && firstName.length() > 0) {
for (int a = firstName.length() - 1; a >= 0; a--) {
if (firstName.charAt(a) == ' ') {
if (a != firstName.length() - 1 && firstName.charAt(a + 1) != ' ') {
if (Build.VERSION.SDK_INT >= 16) {
stringBuilder.append("\u200C");
}
stringBuilder.append(firstName.substring(a + 1, a + 2));
break;
}
}
}
}
if (stringBuilder.length() > 0) {
String text = stringBuilder.toString().toUpperCase();
try {
textLayout = new StaticLayout(text, (smallStyle ? namePaintSmall : namePaint), AndroidUtilities.dp(100), Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false);
if (textLayout.getLineCount() > 0) {
textLeft = textLayout.getLineLeft(0);
textWidth = textLayout.getLineWidth(0);
textHeight = textLayout.getLineBottom(0);
}
} catch (Exception e) {
FileLog.e("tmessages", e);
}
} else {
textLayout = null;
}
}