本文整理匯總了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);
}