當前位置: 首頁>>代碼示例>>Java>>正文


Java TextPaint.set方法代碼示例

本文整理匯總了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;
        }
 
開發者ID:suragch,項目名稱:mongol-library,代碼行數:24,代碼來源:MongolTextLine.java

示例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;
}
 
開發者ID:JackChan1999,項目名稱:letv,代碼行數:20,代碼來源:AndroidDisplayer.java

示例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;
}
 
開發者ID:lisnstatic,項目名稱:live_master,代碼行數:21,代碼來源:AndroidDisplayer.java

示例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);
        }

    }
 
開發者ID:mcassiano,項目名稱:cute-currency-view,代碼行數:30,代碼來源:CuteCurrencyView.java

示例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);
   }
 
開發者ID:stytooldex,項目名稱:stynico,代碼行數:57,代碼來源:AutofitHelper.java

示例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);
}
 
開發者ID:victorminerva,項目名稱:AutoResizeEditText,代碼行數:50,代碼來源:AutofitHelper.java

示例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);
}
 
開發者ID:alibaba,項目名稱:LuaViewPlayground,代碼行數:48,代碼來源:TextUtil.java

示例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;
}
 
開發者ID:wuhighway,項目名稱:DailyStudy,代碼行數:7,代碼來源:AutoFitTextView.java

示例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);
}
 
開發者ID:WrapOnly,項目名稱:android-autofittextview,代碼行數:50,代碼來源:AutofitHelper.java


注:本文中的android.text.TextPaint.set方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。