当前位置: 首页>>代码示例>>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;未经允许,请勿转载。