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


Java Paint.set方法代碼示例

本文整理匯總了Java中android.graphics.Paint.set方法的典型用法代碼示例。如果您正苦於以下問題:Java Paint.set方法的具體用法?Java Paint.set怎麽用?Java Paint.set使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.graphics.Paint的用法示例。


在下文中一共展示了Paint.set方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: refitText

import android.graphics.Paint; //導入方法依賴的package包/類
/**
 * getTextSize 返回值是以像素(px)為單位的,而 setTextSize() 默認是 sp 為單位
 * 因此我們要傳入像素單位 setTextSize(TypedValue.COMPLEX_UNIT_PX, size);
 */
private void refitText(String text, int textWidth) {
    if (textWidth > 0) {
        mTextSize = this.getTextSize();//這個返回的單位為px
        mPaint = new Paint();
        mPaint.set(this.getPaint());
        int drawWid = 0;//drawableLeft,Right,Top,Buttom 所有圖片的寬
        Drawable[] draws = getCompoundDrawables();
        for (int i = 0; i < draws.length; i++) {
            if (draws[i] != null) {
                drawWid += draws[i].getBounds().width();
            }
        }
        //獲得當前TextView的有效寬度
        int availableWidth = textWidth - this.getPaddingLeft()
                - this.getPaddingRight() - getCompoundDrawablePadding() - drawWid;
        //所有字符所占像素寬度
        float textWidths = getTextLength(mTextSize, text);
        while (textWidths > availableWidth) {
            mPaint.setTextSize(--mTextSize);//這裏傳入的單位是 px
            textWidths = getTextLength(mTextSize, text);
        }
        this.setTextSize(TypedValue.COMPLEX_UNIT_PX, mTextSize);//這裏設置單位為 px
    }
}
 
開發者ID:paradoxie,項目名稱:DizzyPassword,代碼行數:29,代碼來源:SingleLineTextView.java

示例2: initialise

import android.graphics.Paint; //導入方法依賴的package包/類
private void initialise() {
    testPaint = new Paint();
    testPaint.set(this.getPaint());
    //max size defaults to the intially specified text size unless it is too small
    maxTextSize = this.getTextSize();
    if (maxTextSize < 9) {
        maxTextSize = 23;
    }
    minTextSize = 8;
}
 
開發者ID:treasure-lau,項目名稱:CSipSimple,代碼行數:11,代碼來源:FitTextView.java

示例3: QMUIFontFitTextView

import android.graphics.Paint; //導入方法依賴的package包/類
public QMUIFontFitTextView(Context context, AttributeSet attrs) {
    super(context, attrs);

    mTestPaint = new Paint();
    mTestPaint.set(this.getPaint());

    TypedArray array = context.obtainStyledAttributes(attrs,
            R.styleable.QMUIFontFitTextView);
    minSize = array.getDimensionPixelSize(
            R.styleable.QMUIFontFitTextView_qmui_minTextSize, Math.round(14 * QMUIDisplayHelper.DENSITY));
    maxSize = array.getDimensionPixelSize(
            R.styleable.QMUIFontFitTextView_qmui_maxTextSize, Math.round(18 * QMUIDisplayHelper.DENSITY));
    array.recycle();
    //max size defaults to the initially specified text size unless it is too small
}
 
開發者ID:coopese,項目名稱:qmui,代碼行數:16,代碼來源:QMUIFontFitTextView.java

示例4: copyPaint

import android.graphics.Paint; //導入方法依賴的package包/類
private static Paint copyPaint(Paint paint, Canvas canvas, String text) {
    Paint myPaint = new Paint();
    myPaint.set(paint);
    myPaint.setTextSize(paint.getTextSize());
    myPaint.setColor(paint.getColor());
    setTextSizeForWidth(myPaint, paint.getTextSize(), canvas.getWidth(), text);
    return myPaint;
}
 
開發者ID:akhilkedia,項目名稱:AllTrans,代碼行數:9,代碼來源:DrawTextHookHandler.java

示例5: initPaints

import android.graphics.Paint; //導入方法依賴的package包/類
/**
 * Initializes the {@code Paint} objects with the appropriate styles.
 */
private void initPaints() {
    mCirclePaint = new Paint();
    mCirclePaint.setAntiAlias(true);
    mCirclePaint.setDither(true);
    mCirclePaint.setColor(mCircleColor);
    mCirclePaint.setStrokeWidth(mCircleStrokeWidth);
    mCirclePaint.setStyle(Paint.Style.STROKE);
    mCirclePaint.setStrokeJoin(Paint.Join.ROUND);
    mCirclePaint.setStrokeCap(Paint.Cap.ROUND);

    mCircleFillPaint = new Paint();
    mCircleFillPaint.setAntiAlias(true);
    mCircleFillPaint.setDither(true);
    mCircleFillPaint.setColor(mCircleFillColor);
    mCircleFillPaint.setStyle(Paint.Style.FILL);

    mCircleProgressPaint = new Paint();
    mCircleProgressPaint.setAntiAlias(true);
    mCircleProgressPaint.setDither(true);
    mCircleProgressPaint.setColor(mCircleProgressColor);
    mCircleProgressPaint.setStrokeWidth(mCircleStrokeWidth);
    mCircleProgressPaint.setStyle(Paint.Style.STROKE);
    mCircleProgressPaint.setStrokeJoin(Paint.Join.ROUND);
    mCircleProgressPaint.setStrokeCap(Paint.Cap.ROUND);

    mCircleProgressGlowPaint = new Paint();
    mCircleProgressGlowPaint.set(mCircleProgressPaint);
    mCircleProgressGlowPaint.setMaskFilter(new BlurMaskFilter((5f * DPTOPX_SCALE), BlurMaskFilter.Blur.NORMAL));

    mPointerPaint = new Paint();
    mPointerPaint.setAntiAlias(true);
    mPointerPaint.setDither(true);
    mPointerPaint.setStyle(Paint.Style.FILL);
    mPointerPaint.setColor(mPointerColor);
    mPointerPaint.setStrokeWidth(mPointerRadius);

    mPointerHaloPaint = new Paint();
    mPointerHaloPaint.set(mPointerPaint);
    mPointerHaloPaint.setColor(mPointerHaloColor);
    mPointerHaloPaint.setAlpha(mPointerAlpha);
    mPointerHaloPaint.setStrokeWidth(mPointerRadius + mPointerHaloWidth);

    mPointerHaloBorderPaint = new Paint();
    mPointerHaloBorderPaint.set(mPointerPaint);
    mPointerHaloBorderPaint.setStrokeWidth(mPointerHaloBorderWidth);
    mPointerHaloBorderPaint.setStyle(Paint.Style.STROKE);

}
 
開發者ID:vpaliyX,項目名稱:Melophile,代碼行數:52,代碼來源:CircularSeekBar.java

示例6: drawLabeles

import android.graphics.Paint; //導入方法依賴的package包/類
protected void drawLabeles(int idx, Canvas c, Paint p)
{
    final Label[] labels = (idx == FunctionIf.X) ? xLabels : yLabels;
    if (labels == null)
    {
        return;
    }
    p.set(getPaint());
    p.setColor(getPaint().getColor());
    p.setTextSize(axisParameters.getLabelTextSize());
    final int labelLineSize = axisParameters.getLabelLineSize();
    for (int i = 0; i < labels.length; i++)
    {
        area.toScreenPoint(labels[i].point, rect, p1);
        String label = labels[i].name;
        p.getTextBounds(label, 0, label.length(), tmpRect);
        p.setStrokeWidth(labelLineSize);
        if (idx == FunctionIf.X)
        {
            c.drawLine(p1.x, p1.y - labelLineSize, p1.x, p1.y + labelLineSize, p);
            tmpRect.offset(p1.x + axisParameters.getGridLineWidth() + 1, p1.y - labelLineSize - 2);
        }
        else
        {
            c.drawLine(p1.x - labelLineSize, p1.y, p1.x + labelLineSize, p1.y, p);
            tmpRect.offset(p1.x + labelLineSize + 2, p1.y - axisParameters.getGridLineWidth() - 2);
        }
        p.setStrokeWidth(1);
        c.drawText(label, tmpRect.left, tmpRect.bottom, p);
    }
}
 
開發者ID:mkulesh,項目名稱:microMathematics,代碼行數:32,代碼來源:PlanePlotView.java

示例7: AddressText

import android.graphics.Paint; //導入方法依賴的package包/類
public AddressText(Context context, AttributeSet attrs) {
	super(context, attrs);

	mTestPaint = new Paint();
	mTestPaint.set(this.getPaint());
}
 
開發者ID:treasure-lau,項目名稱:Linphone4Android,代碼行數:7,代碼來源:AddressText.java

示例8: initPaints

import android.graphics.Paint; //導入方法依賴的package包/類
/**
 * Initializes the {@code Paint} objects with the appropriate styles.
 */
protected void initPaints() {
	mCirclePaint = new Paint();
	mCirclePaint.setAntiAlias(true);
	mCirclePaint.setDither(true);
	mCirclePaint.setColor(mCircleColor);
	mCirclePaint.setStrokeWidth(mCircleStrokeWidth);
	mCirclePaint.setStyle(Paint.Style.STROKE);
	mCirclePaint.setStrokeJoin(Paint.Join.ROUND);
	mCirclePaint.setStrokeCap(Paint.Cap.ROUND);

	mCircleFillPaint = new Paint();
	mCircleFillPaint.setAntiAlias(true);
	mCircleFillPaint.setDither(true);
	mCircleFillPaint.setColor(mCircleFillColor);
	mCircleFillPaint.setStyle(Paint.Style.FILL);

	mCircleProgressPaint = new Paint();
	mCircleProgressPaint.setAntiAlias(true);
	mCircleProgressPaint.setDither(true);
	mCircleProgressPaint.setColor(mCircleProgressColor);
	mCircleProgressPaint.setStrokeWidth(mCircleStrokeWidth);
	mCircleProgressPaint.setStyle(Paint.Style.STROKE);
	mCircleProgressPaint.setStrokeJoin(Paint.Join.ROUND);
	mCircleProgressPaint.setStrokeCap(Paint.Cap.ROUND);

	mCircleProgressGlowPaint = new Paint();
	mCircleProgressGlowPaint.set(mCircleProgressPaint);
	mCircleProgressGlowPaint.setMaskFilter(new BlurMaskFilter((5f * DPTOPX_SCALE), BlurMaskFilter.Blur.NORMAL));

	mPointerPaint = new Paint();
	mPointerPaint.setAntiAlias(true);
	mPointerPaint.setDither(true);
	mPointerPaint.setStyle(Paint.Style.FILL);
	mPointerPaint.setColor(mPointerColor);
	mPointerPaint.setStrokeWidth(mPointerRadius);

	mPointerHaloPaint = new Paint();
	mPointerHaloPaint.set(mPointerPaint);
	mPointerHaloPaint.setColor(mPointerHaloColor);
	mPointerHaloPaint.setAlpha(mPointerAlpha);
	mPointerHaloPaint.setStrokeWidth(mPointerRadius + mPointerHaloWidth);

	mPointerHaloBorderPaint = new Paint();
	mPointerHaloBorderPaint.set(mPointerPaint);
	mPointerHaloBorderPaint.setStrokeWidth(mPointerHaloBorderWidth);
	mPointerHaloBorderPaint.setStyle(Paint.Style.STROKE);

}
 
開發者ID:jonathansautter,項目名稱:AutoOff,代碼行數:52,代碼來源:CircularSeekBar.java

示例9: initialize

import android.graphics.Paint; //導入方法依賴的package包/類
private void initialize() {
    mTestPaint = new Paint();
    mTestPaint.set(this.getPaint());
    defaultTextSize = getTextSize();
}
 
開發者ID:TheUberCatman,項目名稱:crates-io-android,代碼行數:6,代碼來源:FontFitTextView.java

示例10: initPaints

import android.graphics.Paint; //導入方法依賴的package包/類
protected void initPaints() {
    mCirclePaint = new Paint();
    mCirclePaint.setAntiAlias(true);
    mCirclePaint.setDither(true);
    mCirclePaint.setColor(mCircleColor);
    mCirclePaint.setStrokeWidth(mCircleStrokeWidth);
    mCirclePaint.setStyle(Paint.Style.STROKE);
    mCirclePaint.setStrokeJoin(Paint.Join.ROUND);
    mCirclePaint.setStrokeCap(Paint.Cap.ROUND);

    mCircleFillPaint = new Paint();
    mCircleFillPaint.setAntiAlias(true);
    mCircleFillPaint.setDither(true);
    mCircleFillPaint.setColor(mCircleFillColor);
    mCircleFillPaint.setStyle(Paint.Style.FILL);

    mCircleProgressPaint = new Paint();
    mCircleProgressPaint.setAntiAlias(true);
    mCircleProgressPaint.setDither(true);
    mCircleProgressPaint.setColor(mCircleProgressColor);
    mCircleProgressPaint.setStrokeWidth(mCircleStrokeWidth);
    mCircleProgressPaint.setStyle(Paint.Style.STROKE);
    mCircleProgressPaint.setStrokeJoin(Paint.Join.ROUND);
    mCircleProgressPaint.setStrokeCap(Paint.Cap.ROUND);

    mCircleProgressGlowPaint = new Paint();
    mCircleProgressGlowPaint.set(mCircleProgressPaint);
    mCircleProgressGlowPaint.setMaskFilter(new BlurMaskFilter((5f * DPTOPX_SCALE), BlurMaskFilter.Blur.NORMAL));

    mPointerPaint = new Paint();
    mPointerPaint.setAntiAlias(true);
    mPointerPaint.setDither(true);
    mPointerPaint.setStyle(Paint.Style.FILL);
    mPointerPaint.setColor(mPointerColor);
    mPointerPaint.setStrokeWidth(mPointerRadius);

    mPointerHaloPaint = new Paint();
    mPointerHaloPaint.set(mPointerPaint);
    mPointerHaloPaint.setColor(mPointerHaloColor);
    mPointerHaloPaint.setAlpha(mPointerAlpha);
    mPointerHaloPaint.setStrokeWidth(mPointerRadius + mPointerHaloWidth);

    mPointerHaloBorderPaint = new Paint();
    mPointerHaloBorderPaint.set(mPointerPaint);
    mPointerHaloBorderPaint.setStrokeWidth(mPointerHaloBorderWidth);
    mPointerHaloBorderPaint.setStyle(Paint.Style.STROKE);

}
 
開發者ID:RajneeshSingh007,項目名稱:MusicX-music-player,代碼行數:49,代碼來源:CircularSeekBar.java


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