本文整理汇总了Java中android.text.TextPaint.set方法的典型用法代码示例。如果您正苦于以下问题:Java TextPaint.set方法的具体用法?Java TextPaint.set怎么用?Java TextPaint.set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.text.TextPaint
的用法示例。
在下文中一共展示了TextPaint.set方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: TextRun
import android.text.TextPaint; //导入方法依赖的package包/类
TextRun(int offset, int length, boolean isRotated, boolean isSpanned) {
this.offset = offset;
this.length = length;
this.isRotated = isRotated;
TextPaint wp;
if (isSpanned) {
wp = mWorkPaint;
wp.set(mPaint);
MetricAffectingSpan[] spans = ((Spanned) mText).getSpans(offset, offset + length, MetricAffectingSpan.class);
for(MetricAffectingSpan span : spans) {
span.updateDrawState(wp);
}
} else {
wp = mPaint;
}
// just record the normal non-rotated values here
// measure and draw will take rotation into account
measuredWidth = wp.measureText(mText, offset, offset + length);
measuredHeight = wp.getFontMetrics().bottom - wp.getFontMetrics().top;
}
示例2: getPaint
import android.text.TextPaint; //导入方法依赖的package包/类
private synchronized TextPaint getPaint(BaseDanmaku danmaku, boolean quick) {
TextPaint paint;
if (quick) {
paint = this.PAINT_DUPLICATE;
paint.set(this.PAINT);
} else {
paint = this.PAINT;
}
paint.reset();
paint.setTextSize(danmaku.textSize);
applyTextScaleConfig(danmaku, paint);
if (!this.HAS_SHADOW || this.SHADOW_RADIUS <= 0.0f || danmaku.textShadowColor == 0) {
paint.clearShadowLayer();
} else {
paint.setShadowLayer(this.SHADOW_RADIUS, 0.0f, 0.0f, danmaku.textShadowColor);
}
paint.setAntiAlias(this.ANTI_ALIAS);
return paint;
}
示例3: getPaint
import android.text.TextPaint; //导入方法依赖的package包/类
private synchronized TextPaint getPaint(BaseDanmaku danmaku, boolean fromWorkerThread) {
TextPaint paint;
if (fromWorkerThread) {
paint = PAINT;
} else {
paint = PAINT_DUPLICATE;
paint.set(PAINT);
}
paint.setTextSize(danmaku.textSize);
applyTextScaleConfig(danmaku, paint);
//ignore the transparent textShadowColor
if (!HAS_SHADOW || SHADOW_RADIUS <= 0 || danmaku.textShadowColor == 0) {
paint.clearShadowLayer();
} else {
paint.setShadowLayer(SHADOW_RADIUS, 0, 0, danmaku.textShadowColor);
}
paint.setAntiAlias(ANTI_ALIAS);
return paint;
}
示例4: startAnimation
import android.text.TextPaint; //导入方法依赖的package包/类
public void startAnimation() {
actualEditText.setVisibility(INVISIBLE);
animatedPlaceholder.setVisibility(INVISIBLE);
if (TextUtils.isEmpty(actualEditText.getText())
&& TextUtils.isEmpty(actualEditText.getHint())) {
// don't do anything if everything is empty
// but make the EditText visible and say bye to placeholder
actualEditText.setVisibility(VISIBLE);
animatedPlaceholder.setVisibility(GONE);
return;
}
TextPaint paint = new TextPaint();
paint.set(actualEditText.getPaint());
// decides what is going to be animated
if (TextUtils.isEmpty(actualEditText.getText())) {
// animate hint
paint.setColor(actualEditText.getCurrentHintTextColor());
animateCharSequence(actualEditText.getHint(), paint);
} else {
// animate text
paint.setColor(actualEditText.getCurrentTextColor());
animateCharSequence(actualEditText.getText(), paint);
}
}
示例5: autofit
import android.text.TextPaint; //导入方法依赖的package包/类
/**
* Re-sizes the textSize of the TextView so that the text fits within the bounds of the View.
*/
private static void autofit(AppCompatTextView view, TextPaint paint, float minTextSize, float maxTextSize,
int maxLines, float precision)
{
if (maxLines <= 0 || maxLines == Integer.MAX_VALUE)
{
// Don't auto-size since there's no limit on lines.
return;
}
int targetWidth = view.getWidth() - view.getPaddingLeft() - view.getPaddingRight();
if (targetWidth <= 0)
{
return;
}
CharSequence text = view.getText();
TransformationMethod method = view.getTransformationMethod();
if (method != null)
{
text = method.getTransformation(text, view);
}
Context context = view.getContext();
Resources r = Resources.getSystem();
DisplayMetrics displayMetrics;
float size = maxTextSize;
float high = size;
float low = 0;
if (context != null)
{
r = context.getResources();
}
displayMetrics = r.getDisplayMetrics();
paint.set(view.getPaint());
paint.setTextSize(size);
if ((maxLines == 1 && paint.measureText(text, 0, text.length()) > targetWidth)
|| getLineCount(text, paint, size, targetWidth, displayMetrics) > maxLines)
{
size = getAutofitTextSize(text, paint, targetWidth, maxLines, low, high, precision,
displayMetrics);
}
if (size < minTextSize)
{
size = minTextSize;
}
view.setTextSize(TypedValue.COMPLEX_UNIT_PX, size);
}
示例6: autofit
import android.text.TextPaint; //导入方法依赖的package包/类
/**
* Re-sizes the textSize of the TextView so that the text fits within the bounds of the View.
*/
private static void autofit(TextView view, TextPaint paint, float minTextSize, float maxTextSize,
int maxLines, float precision) {
if (maxLines <= 0 || maxLines == Integer.MAX_VALUE) {
// Don't auto-size since there's no limit on lines.
return;
}
int targetWidth = view.getWidth() - view.getPaddingLeft() - view.getPaddingRight();
if (targetWidth <= 0) {
return;
}
CharSequence text = view.getText();
TransformationMethod method = view.getTransformationMethod();
if (method != null) {
text = method.getTransformation(text, view);
}
Context context = view.getContext();
Resources r = Resources.getSystem();
DisplayMetrics displayMetrics;
float size = maxTextSize;
float high = size;
float low = 0;
if (context != null) {
r = context.getResources();
}
displayMetrics = r.getDisplayMetrics();
paint.set(view.getPaint());
paint.setTextSize(size);
if ((maxLines == 1 && paint.measureText(text, 0, text.length()) > targetWidth)
|| getLineCount(text, paint, size, targetWidth, displayMetrics) > maxLines) {
size = getAutofitTextSize(text, paint, targetWidth, maxLines, low, high, precision,
displayMetrics);
}
if (size < minTextSize) {
size = minTextSize;
}
view.setTextSize(TypedValue.COMPLEX_UNIT_PX, size);
}
示例7: adjustTextSize
import android.text.TextPaint; //导入方法依赖的package包/类
/**
* Re-sizes the textSize of the TextView so that the text fits within the bounds of the View.
*/
private static void adjustTextSize(TextView view, TextPaint paint, float minTextSize, float maxTextSize, int maxLines, float precision) {
if (maxLines <= 0 || maxLines == Integer.MAX_VALUE) {
// Don't auto-size since there's no limit on lines.
return;
}
int targetWidth = view.getWidth() - view.getPaddingLeft() - view.getPaddingRight();
if (targetWidth <= 0) {
return;
}
CharSequence text = view.getText();
TransformationMethod method = view.getTransformationMethod();
if (method != null) {
text = method.getTransformation(text, view);
}
Context context = view.getContext();
Resources r = Resources.getSystem();
DisplayMetrics displayMetrics;
float size = maxTextSize;
float high = size;
float low = 0;
if (context != null) {
r = context.getResources();
}
displayMetrics = r.getDisplayMetrics();
paint.set(view.getPaint());
paint.setTextSize(size);
if ((maxLines == 1 && paint.measureText(text, 0, text.length()) > targetWidth)
|| getLineCount(text, paint, size, targetWidth, displayMetrics) > maxLines) {
size = getAutofitTextSize(text, paint, targetWidth, maxLines, low, high, precision, displayMetrics);
}
if (size < minTextSize) {
size = minTextSize;
}
view.setTextSize(TypedValue.COMPLEX_UNIT_PX, size);
}
示例8: initialise
import android.text.TextPaint; //导入方法依赖的package包/类
private void initialise() {
testPaint = new TextPaint();
testPaint.set(this.getPaint());
maxTextSize = this.getTextSize();
minTextSize = DEFAULT_MIN_TEXT_SIZE;
}
示例9: autofit
import android.text.TextPaint; //导入方法依赖的package包/类
/**
* Re-sizes the textSize of the TextView so that the text fits within the bounds of the View.
*/
private static void autofit(TextView view, TextPaint paint, float minTextSize, float maxTextSize,
int maxLines, float precision) {
if (maxLines <= 0 || maxLines == Integer.MAX_VALUE) {
// Don't auto-size since there's no limit on lines.
return;
}
int targetWidth = view.getWidth() - view.getPaddingLeft() - view.getPaddingRight();
if (targetWidth <= 0) {
return;
}
CharSequence text = view.getText();
TransformationMethod method = view.getTransformationMethod();
if (method != null) {
text = method.getTransformation(text, view);
}
Context context = view.getContext();
Resources r = Resources.getSystem();
DisplayMetrics displayMetrics;
float size = maxTextSize;
float high = size;
float low = 0;
if (context != null) {
r = context.getResources();
}
displayMetrics = r.getDisplayMetrics();
paint.set(view.getPaint());
paint.setTextSize(size);
if ((maxLines == 1 && paint.measureText(text, 0, text.length()) > targetWidth)
|| getLineCount(text, paint, size, targetWidth, displayMetrics) > maxLines) {
size = getAutofitTextSize(text, paint, targetWidth, maxLines, low, high, precision,
displayMetrics);
}
if (size < minTextSize) {
size = minTextSize;
}
view.setTextSize(TypedValue.COMPLEX_UNIT_PX, size);
}