Java Code Examples for android.text.TextPaint.setDither()

The following are Jave code examples for showing how to use setDither() of the android.text.TextPaint class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: Renrentou   File: CountDownView.java   Source Code and License Vote up 6 votes
private void init() {
    circlePaint = new Paint();
    circlePaint.setAntiAlias(true);
    circlePaint.setDither(true);
    circlePaint.setColor(backgroundColor);
    circlePaint.setStyle(Paint.Style.FILL);

    textPaint = new TextPaint();
    textPaint.setAntiAlias(true);
    textPaint.setDither(true);
    textPaint.setColor(textColor);
    textPaint.setTextSize(textSize);
    textPaint.setTextAlign(Paint.Align.CENTER);

    borderPaint = new Paint();
    borderPaint.setAntiAlias(true);
    borderPaint.setDither(true);
    borderPaint.setColor(borderColor);
    borderPaint.setStrokeWidth(borderWidth);
    borderPaint.setStyle(Paint.Style.STROKE);

    int textWidth = (int) textPaint.measureText(text.substring(0, (text.length() + 1) / 2));
    staticLayout = new StaticLayout(text, textPaint, textWidth, Layout.Alignment.ALIGN_NORMAL, 1F, 0, false);
}
 
Example 2
Project: jackknife   File: LetterView.java   Source Code and License Vote up 5 votes
private void initPaint() {
    mPaint = new TextPaint();
    mPaint.setTextSize(mTextSize);
    mPaint.setColor(mTextColor);
    mPaint.setTypeface(Typeface.DEFAULT);
    mPaint.setAntiAlias(true);
    mPaint.setDither(true);
}
 
Example 3
Project: PureMusic   File: LyricView.java   Source Code and License Vote up 5 votes
private void initPaint() {
    mTextPaint = new TextPaint();
    mTextPaint.setDither(true);
    mTextPaint.setAntiAlias(true);
    switch (mTextAlign) {
        case LEFT:
            mTextPaint.setTextAlign(Paint.Align.LEFT);
            break;
        case CENTER:
            mTextPaint.setTextAlign(Paint.Align.CENTER);
            break;
        case RIGHT:
            mTextPaint.setTextAlign(Paint.Align.RIGHT);
            break;
    }

    mBtnPlayPaint = new Paint();
    mBtnPlayPaint.setDither(true);
    mBtnPlayPaint.setAntiAlias(true);
    mBtnPlayPaint.setColor(mBtnColor);
    mBtnPlayPaint.setStyle(Paint.Style.FILL_AND_STROKE);
    mBtnPlayPaint.setAlpha(128);

    mLinePaint = new Paint();
    mLinePaint.setDither(true);
    mLinePaint.setAntiAlias(true);
    mLinePaint.setColor(mLineColor);
    mLinePaint.setAlpha(64);
    mLinePaint.setStrokeWidth(1.0f);
    mLinePaint.setStyle(Paint.Style.STROKE);

    mTimerPaint = new Paint();
    mTimerPaint.setDither(true);
    mTimerPaint.setAntiAlias(true);
    mTimerPaint.setColor(Color.WHITE);
    mTimerPaint.setTextAlign(Paint.Align.RIGHT);
    mTimerPaint.setTextSize(getRawSize(TypedValue.COMPLEX_UNIT_SP, INDICATOR_TIME_TEXT_SIZE));


}
 
Example 4
Project: OSchina_resources_android   File: PortraitView.java   Source Code and License Vote up 4 votes
@SuppressWarnings("ResourceAsColor")
private Bitmap buildSrcFromName(final String firstChar, int w, int h) {
    if (w == Target.SIZE_ORIGINAL || w <= 0)
        w = 80;
    if (h == Target.SIZE_ORIGINAL || h <= 0)
        h = 80;

    final int size = Math.max(Math.min(Math.min(w, h), 220), 64);
    final float fontSize = size * 0.4f;
    log("firstChar:" + firstChar + " size:" + size + " fontSize:" + fontSize);

    Bitmap bitmap = Bitmap.createBitmap(size, size, Bitmap.Config.RGB_565);

    TextPaint paint = new TextPaint(Paint.ANTI_ALIAS_FLAG);
    paint.setAntiAlias(true);
    paint.setDither(true);
    paint.setColor(Color.WHITE);
    paint.setTextAlign(Paint.Align.CENTER);
    paint.setTextSize(fontSize);
    paint.setTypeface(Typeface.SANS_SERIF);

    // check ASCII
    final int charNum = Character.getNumericValue(firstChar.charAt(0));
    if (charNum > 0 && charNum < 177) {
        Typeface typeface = getFont(getContext(), "Numans-Regular.otf");
        if (typeface != null)
            paint.setTypeface(typeface);
    }

    Rect rect = new Rect();
    paint.getTextBounds(firstChar, 0, 1, rect);
    int fontHeight = rect.height();
    log(rect.toString());

    int fontHalfH = fontHeight >> 1;
    int centerX = bitmap.getWidth() >> 1;
    int centerY = bitmap.getHeight() >> 1;

    Canvas canvas = new Canvas(bitmap);
    canvas.drawColor(getBackgroundColor(firstChar));
    canvas.drawText(firstChar, centerX, centerY + fontHalfH, paint);

    return bitmap;
}
 
Example 5
Project: RetroMusicPlayer   File: LyricView.java   Source Code and License Vote up 4 votes
private void initPaint() {
    mTextPaint = new TextPaint();
    mTextPaint.setDither(true);
    mTextPaint.setAntiAlias(true);
    Typeface typeface = Typeface.createFromAsset(getContext().getAssets(), "fonts/circular_std_book.otf");
    mTextPaint.setTypeface(typeface);

    switch (mTextAlign) {
        case LEFT:
            mTextPaint.setTextAlign(Paint.Align.LEFT);
            break;
        case CENTER:
            mTextPaint.setTextAlign(Paint.Align.CENTER);
            break;
        case RIGHT:
            mTextPaint.setTextAlign(Paint.Align.RIGHT);
            break;
    }

    mBtnPlayPaint = new Paint();
    mBtnPlayPaint.setDither(true);
    mBtnPlayPaint.setAntiAlias(true);
    mBtnPlayPaint.setColor(mBtnColor);
    mBtnPlayPaint.setStyle(Paint.Style.FILL_AND_STROKE);
    mBtnPlayPaint.setAlpha(128);

    mLinePaint = new Paint();
    mLinePaint.setDither(true);
    mLinePaint.setAntiAlias(true);
    mLinePaint.setColor(mLineColor);
    mLinePaint.setAlpha(64);
    mLinePaint.setStrokeWidth(1.0f);
    mLinePaint.setStyle(Paint.Style.STROKE);

    mTimerPaint = new Paint();
    mTimerPaint.setDither(true);
    mTimerPaint.setAntiAlias(true);
    mTimerPaint.setColor(Color.WHITE);
    mTimerPaint.setTextAlign(Paint.Align.RIGHT);
    mTimerPaint.setTextSize(getRawSize(TypedValue.COMPLEX_UNIT_SP, INDICATOR_TIME_TEXT_SIZE));


}
 
Example 6
Project: mongol-library   File: KeyImage.java   Source Code and License Vote up 3 votes
private void initPaints() {

        mImagePaint = new TextPaint(Paint.ANTI_ALIAS_FLAG);
        mImagePaint.setFilterBitmap(true);
        mImagePaint.setDither(true);



        //mImagePaint.setColor(Color.YELLOW);
    }