本文整理匯總了Java中android.text.TextPaint.setAntiAlias方法的典型用法代碼示例。如果您正苦於以下問題:Java TextPaint.setAntiAlias方法的具體用法?Java TextPaint.setAntiAlias怎麽用?Java TextPaint.setAntiAlias使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.text.TextPaint
的用法示例。
在下文中一共展示了TextPaint.setAntiAlias方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: drawCenterMultiText1
import android.text.TextPaint; //導入方法依賴的package包/類
/**
* 繪製多行居中文本(方式1)
*
* @param canvas 畫布
*/
private void drawCenterMultiText1(Canvas canvas) {
String text = "ABC";
// 畫筆
TextPaint textPaint = new TextPaint();
textPaint.setAntiAlias(true);
textPaint.setColor(Color.GRAY);
// 設置寬度超過50dp時換行
StaticLayout staticLayout = new StaticLayout(text, textPaint, dp2px(50),
Layout.Alignment.ALIGN_CENTER, 1, 0, false);
canvas.save();
// StaticLayout默認從(0,0)點開始繪製
// 如果需要調整位置,隻能在繪製之前移動Canvas的起始坐標
canvas.translate(-staticLayout.getWidth() / 2, -staticLayout.getHeight() / 2);
staticLayout.draw(canvas);
canvas.restore();
}
示例2: initPaint
import android.text.TextPaint; //導入方法依賴的package包/類
private void initPaint() {
//繪製提示的畫筆
mTipPaint = new Paint();
mTipPaint.setColor(mPageView.getTextColor());
mTipPaint.setTextAlign(Paint.Align.LEFT);//繪製的起始點
mTipPaint.setTextSize(ScreenUtils.spToPx(mContext, DEFAULT_TIP_SIZE));//Tip默認的字體大小
mTipPaint.setAntiAlias(true);
mTipPaint.setSubpixelText(true);
//繪製頁麵內容的畫筆
mTextPaint = new TextPaint();
mTextPaint.setColor(mPageView.getTextColor());
mTextPaint.setTextSize(mPageView.getTextSize());
mTextPaint.setAntiAlias(true);
mBgPaint = new Paint();
mBgPaint.setColor(mPageView.getPageBackground());
mBatteryPaint = new Paint();
mBatteryPaint.setAntiAlias(true);
mBatteryPaint.setDither(true);
mBatteryPaint.setColor(mPageView.getTextColor());
}
示例3: TMReminderTagsView
import android.text.TextPaint; //導入方法依賴的package包/類
public TMReminderTagsView(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
if (mDensity == -1) {
initWith(context);
}
textPaint = new TextPaint();
textPaint.setAntiAlias(true);
textPaint.setColor(Color.rgb(255, 59, 68));
textPaint.setTextSize(dp2px(10));
bgPaint = new Paint();
bgPaint.setColor(Color.rgb(250, 211, 213));
tagsGap = dp2px(7);
hPadding = dp2px(3);
tagRect = new Rect();
textFontMetrics = textPaint.getFontMetrics();
}
示例4: initPaint
import android.text.TextPaint; //導入方法依賴的package包/類
private void initPaint() {
mTextPaint = new TextPaint();
mTextPaint.setAntiAlias(true);
mTextPaint.setTextSize(getTextSize());
mTextPaint.setColor(mColor);
mTextPaint.setStyle(Paint.Style.FILL);
mTextPaint.setTypeface(getTypeface());
mTextPaintOutline = new TextPaint();
mTextPaintOutline.setAntiAlias(true);
mTextPaintOutline.setTextSize(getTextSize());
mTextPaintOutline.setColor(mBorderColor);
mTextPaintOutline.setStyle(Paint.Style.STROKE);
mTextPaintOutline.setTypeface(getTypeface());
mTextPaintOutline.setStrokeWidth(mBorderSize);
}
示例5: initPaint
import android.text.TextPaint; //導入方法依賴的package包/類
private void initPaint() {
mTextPaint = new TextPaint();
mTextPaint.setAntiAlias(true);
mTextPaint.setTextSize(getTextSize());
mTextPaint.setColor(mColor);
mTextPaint.setStyle(Paint.Style.FILL);
mTextPaint.setTypeface(getTypeface());
mTextPaintOutline = new TextPaint();
mTextPaintOutline.setAntiAlias(true);
mTextPaintOutline.setTextSize(getTextSize());
mTextPaintOutline.setColor(mBorderColor);
mTextPaintOutline.setStyle(Paint.Style.STROKE);
mTextPaintOutline.setTypeface(getTypeface());
mTextPaintOutline.setStrokeWidth(mBorderSize);
}
示例6: init
import android.text.TextPaint; //導入方法依賴的package包/類
private void init() {
mTextPaint = new TextPaint();
mTextPaint.setAntiAlias(true);
if (mTextSizePx <= 0) {
mTextSizePx = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP,
DEFAULT_FONT_SIZE_SP, getResources().getDisplayMetrics());
}
mTextPaint.setTextSize(mTextSizePx);
mTextPaint.setColor(mTextColor);
mTypeface = MongolFont.get(MongolFont.QAGAN, mContext);
mTextPaint.setTypeface(mTypeface);
mRenderer = MongolCode.INSTANCE;
if (mUnicodeText == null) {
mUnicodeText = "";
}
mGlyphText = mRenderer.unicodeToMenksoft(mUnicodeText);
}
示例7: init
import android.text.TextPaint; //導入方法依賴的package包/類
private void init() {
bgPaint = new Paint();
bgPaint.setAntiAlias(true);
bgPaint.setStyle(Paint.Style.FILL);
bgPaint.setColor(bgColor);
bgPaint.setStrokeWidth(lineBgWidth);
proPaint = new Paint();
proPaint.setAntiAlias(true);
proPaint.setStyle(Paint.Style.FILL);
proPaint.setColor(proColor);
proPaint.setStrokeWidth(lineProWidth);
textPaint = new TextPaint();
textPaint.setTextSize(textsize);
textPaint.setAntiAlias(true);
}
示例8: getTextPaint
import android.text.TextPaint; //導入方法依賴的package包/類
private TextPaint getTextPaint() {
TextPaint textPaint = new TextPaint();
textPaint.setColor(this.textColor);
textPaint.linkColor = this.textColor;
textPaint.setAntiAlias(true);
textPaint.setTextSize(this.textSize);
textPaint.setTypeface(this.typeFace);
return textPaint;
}
示例9: textPaint
import android.text.TextPaint; //導入方法依賴的package包/類
private TextPaint textPaint() {
final TextPaint paint = new TextPaint();
paint.setColor(Color.BLACK);
paint.setAntiAlias(true);
paint.setTextSize(24);
paint.setTextAlign(Paint.Align.CENTER);
return paint;
}
示例10: initPaint
import android.text.TextPaint; //導入方法依賴的package包/類
private void initPaint()
{
mTextPaint = new TextPaint();
mTextPaint.setAntiAlias(true);
mTextPaint.setTextSize(mTextSize);
mTextPaint.setColor(mTextColor);
mTextPaint.setTextAlign(Paint.Align.LEFT);
}
示例11: NineGridViewWrapper
import android.text.TextPaint; //導入方法依賴的package包/類
public NineGridViewWrapper(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
//轉化單位
textSize = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, textSize, getContext().getResources().getDisplayMetrics());
textPaint = new TextPaint();
textPaint.setTextAlign(Paint.Align.CENTER); //文字居中對齊
textPaint.setAntiAlias(true); //抗鋸齒
textPaint.setTextSize(textSize); //設置文字大小
textPaint.setColor(textColor); //設置文字顏色
}
示例12: initPainters
import android.text.TextPaint; //導入方法依賴的package包/類
protected void initPainters() {
textPaint = new TextPaint();
textPaint.setColor(textColor);
textPaint.setTextSize(textSize);
textPaint.setAntiAlias(true);
paint.setAntiAlias(true);
}
示例13: createTextLayout
import android.text.TextPaint; //導入方法依賴的package包/類
private StaticLayout createTextLayout(String text, int color, float fontSize, int width) {
TextPaint paint = new TextPaint();
paint.setColor(color);
paint.setTextSize(fontSize);
paint.setTypeface(Typeface.SANS_SERIF);
paint.setAntiAlias(true);
return (new StaticLayout(text, paint, width, Layout.Alignment.ALIGN_CENTER, 1.1f, 0f, true));
}
示例14: initPaint
import android.text.TextPaint; //導入方法依賴的package包/類
private void initPaint() {
mValuePaint = new TextPaint();
mValuePaint.setAntiAlias(antiAlias);
mValuePaint.setTextSize(mValueSize);
mValuePaint.setColor(mValueColor);
mValuePaint.setTypeface(Typeface.DEFAULT_BOLD);
mValuePaint.setTextAlign(Paint.Align.CENTER);
mUnitPaint = new TextPaint();
mUnitPaint.setAntiAlias(antiAlias);
mUnitPaint.setTextSize(mUnitSize);
mUnitPaint.setColor(mUnitColor);
mUnitPaint.setTextAlign(Paint.Align.CENTER);
mArcPaint = new Paint();
mArcPaint.setAntiAlias(antiAlias);
mArcPaint.setStyle(Paint.Style.STROKE);
mArcPaint.setStrokeWidth(mArcWidth);
mArcPaint.setStrokeCap(Paint.Cap.ROUND);
mBgArcPaint = new Paint();
mBgArcPaint.setAntiAlias(antiAlias);
mBgArcPaint.setColor(mBgArcColor);
mBgArcPaint.setStyle(Paint.Style.STROKE);
mBgArcPaint.setStrokeWidth(mBgArcWidth);
mBgArcPaint.setStrokeCap(Paint.Cap.ROUND);
mDialPaint = new Paint();
mDialPaint.setAntiAlias(antiAlias);
mDialPaint.setColor(mDialColor);
mDialPaint.setStrokeWidth(mDialWidth);
}
示例15: init
import android.text.TextPaint; //導入方法依賴的package包/類
private void init() {
float dSize = TypedValue.applyDimension(
TypedValue.COMPLEX_UNIT_SP,
15,
getContext().getResources().getDisplayMetrics());
tBuilder = new StringBuilder("");
setText("");
mTpaint = new TextPaint();
mTpaint.setColor(Color.BLUE);
mTpaint.setAntiAlias(true);
mTpaint.setTextSize(dSize);
mTpaint.setStyle(Paint.Style.FILL);
tRect = new Rect();
setWillNotDraw(false);
mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
mPaint.setStyle(Paint.Style.FILL);
mPaint.setFilterBitmap(true);
camera = new Camera();
matrix = new Matrix();
mPath = new Path();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
mViewOutlineProvider = new ViewOutlineProvider() {
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
@Override
public void getOutline(View view, Outline outline) {
if (mPath.isConvex()) outline.setConvexPath(mPath);
}
};
}
}