本文整理匯總了Java中android.text.TextPaint.setDither方法的典型用法代碼示例。如果您正苦於以下問題:Java TextPaint.setDither方法的具體用法?Java TextPaint.setDither怎麽用?Java TextPaint.setDither使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.text.TextPaint
的用法示例。
在下文中一共展示了TextPaint.setDither方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: init
import android.text.TextPaint; //導入方法依賴的package包/類
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);
}
示例2: initPaint
import android.text.TextPaint; //導入方法依賴的package包/類
private void initPaint() {
mPaint = new TextPaint();
mPaint.setTextSize(mTextSize);
mPaint.setColor(mTextColor);
mPaint.setTypeface(Typeface.DEFAULT);
mPaint.setAntiAlias(true);
mPaint.setDither(true);
}
示例3: initPaint
import android.text.TextPaint; //導入方法依賴的package包/類
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));
}
示例4: buildSrcFromName
import android.text.TextPaint; //導入方法依賴的package包/類
@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;
}
示例5: initPaint
import android.text.TextPaint; //導入方法依賴的package包/類
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));
}
示例6: initPaints
import android.text.TextPaint; //導入方法依賴的package包/類
private void initPaints() {
mImagePaint = new TextPaint(Paint.ANTI_ALIAS_FLAG);
mImagePaint.setFilterBitmap(true);
mImagePaint.setDither(true);
//mImagePaint.setColor(Color.YELLOW);
}