本文整理汇总了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);
}
};
}
}