本文整理匯總了Java中android.text.TextPaint.setStyle方法的典型用法代碼示例。如果您正苦於以下問題:Java TextPaint.setStyle方法的具體用法?Java TextPaint.setStyle怎麽用?Java TextPaint.setStyle使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.text.TextPaint
的用法示例。
在下文中一共展示了TextPaint.setStyle方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: 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);
}
示例2: init
import android.text.TextPaint; //導入方法依賴的package包/類
private void init(AttributeSet attrs, int defStyle) {
this.attrs = attrs;//TODO: check
this.defStyle = defStyle;
textPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG);
textPaint.setColor(Color.WHITE);//this.getCurrentTextColor()
textPaint.setStyle(Paint.Style.FILL);
cursorPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
cursorPaint.setColor(Color.WHITE);
cursorPaint.setStyle(Paint.Style.FILL);
cursorTransparentPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
cursorTransparentPaint.setColor(Color.TRANSPARENT);
cursorPaint.setStyle(Paint.Style.FILL);
text = this.getText();
this.postDelayed(new Runnable() {
@Override
public void run() {
prepareAnimate();
}
}, 50);
}
示例3: onDraw
import android.text.TextPaint; //導入方法依賴的package包/類
@Override
public void onDraw(Canvas canvas) {
super.onDraw(canvas);
int restoreColor = this.getCurrentTextColor();
if (strokeColor != null) {
TextPaint paint = this.getPaint();
paint.setStyle(Paint.Style.STROKE);
paint.setStrokeJoin(strokeJoin);
paint.setStrokeMiter(strokeMiter);
this.setTextColor(strokeColor);
paint.setStrokeWidth(strokeWidth);
super.onDraw(canvas);
paint.setStyle(Paint.Style.FILL);
this.setTextColor(restoreColor);
}
}
示例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: drawLeadingMargin
import android.text.TextPaint; //導入方法依賴的package包/類
public void drawLeadingMargin(Canvas c, Paint p, int x, int dir, int top, int baseline,
int bottom, CharSequence text, int start, int end, boolean first, Layout l) {
if (first) {
TextPaint paint = new TextPaint(p);
paint.setStyle(Paint.Style.FILL);
if (options.textSize != -1) {
paint.setTextSize(options.textSize);
}
if (options.textColor != -1) {
paint.setColor(options.textColor);
}
if (options.typeface != null) {
paint.setTypeface(options.typeface);
}
c.save();
c.drawText(data, x + options.leadWidth, baseline, paint);
c.restore();
}
}
示例6: Settings
import android.text.TextPaint; //導入方法依賴的package包/類
public Settings(Sushi slidr) {
this.slidr = slidr;
paintBar = new Paint();
paintBar.setAntiAlias(true);
paintBar.setStrokeWidth(2);
paintBar.setColor(colorBackground);
paintTextTop = new TextPaint();
paintTextTop.setAntiAlias(true);
paintTextTop.setStyle(Paint.Style.FILL);
paintTextTop.setColor(textColor);
paintTextTop.setTextSize(dpToPx(textSize));
paintTextBubble = new TextPaint();
paintTextBubble.setAntiAlias(true);
paintTextBubble.setStyle(Paint.Style.FILL);
paintTextBubble.setColor(Color.WHITE);
paintTextBubble.setStrokeWidth(2);
paintTextBubble.setTextSize(dpToPx(textSizeBubble));
paintBubble = new Paint();
paintBubble.setAntiAlias(true);
paintBubble.setStrokeWidth(3);
}
示例7: updateDrawState
import android.text.TextPaint; //導入方法依賴的package包/類
@Override
public void updateDrawState(TextPaint paint) {
final float newStrokeWidth = (mWeight / (UDFontWeight.WEIGHT_NORMAL_INT + 0.0f));
if (paint.getStyle() == Paint.Style.FILL) {
paint.setStyle(Paint.Style.FILL_AND_STROKE);
}
paint.setStrokeWidth(newStrokeWidth);
}
示例8: PrimitiveDrawer
import android.text.TextPaint; //導入方法依賴的package包/類
public PrimitiveDrawer(Context context, AttributeSet attributeSet) {
super(context, attributeSet);
paint = new TextPaint();
paint.setStyle(Paint.Style.FILL);
paint.setAntiAlias(true);
paint.setColor(0xffffffff);
paint.setStrokeWidth(1.f);
paint.setTextSize(35.f);
paint.setTextAlign(Paint.Align.LEFT);
}
示例9: initPaint
import android.text.TextPaint; //導入方法依賴的package包/類
private void initPaint(){
//繪製提示的畫筆
mTipPaint = new Paint();
mTipPaint.setColor(mTextColor);
mTipPaint.setTextAlign(Paint.Align.LEFT);//繪製的起始點
mTipPaint.setTextSize(ScreenUtils.spToPx(DEFAULT_TIP_SIZE));//Tip默認的字體大小
mTipPaint.setAntiAlias(true);
mTipPaint.setSubpixelText(true);
//繪製頁麵內容的畫筆
mTextPaint = new TextPaint();
mTextPaint.setColor(mTextColor);
mTextPaint.setTextSize(mTextSize);
mTextPaint.setAntiAlias(true);
//繪製標題的畫筆
mTitlePaint = new TextPaint();
mTitlePaint.setColor(mTextColor);
mTitlePaint.setTextSize(mTitleSize);
mTitlePaint.setStyle(Paint.Style.FILL_AND_STROKE);
mTitlePaint.setTypeface(Typeface.DEFAULT_BOLD);
mTitlePaint.setAntiAlias(true);
//繪製背景的畫筆
mBgPaint = new Paint();
mBgPaint.setColor(mPageBg);
mBatteryPaint = new Paint();
mBatteryPaint.setAntiAlias(true);
mBatteryPaint.setDither(true);
if (isNightMode){
mBatteryPaint.setColor(Color.WHITE);
}
else {
mBatteryPaint.setColor(Color.BLACK);
}
}
示例10: PinView
import android.text.TextPaint; //導入方法依賴的package包/類
public PinView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
final Resources res = getResources();
mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
mPaint.setStyle(Paint.Style.STROKE);
mTextPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG);
mTextPaint.density = res.getDisplayMetrics().density;
mTextPaint.setStyle(Paint.Style.FILL);
mTextPaint.setTextSize(getTextSize());
mAnimatorTextPaint = new TextPaint(mTextPaint);
final Resources.Theme theme = context.getTheme();
TypedArray a = theme.obtainStyledAttributes(attrs, R.styleable.PinView, defStyleAttr, 0);
mViewType = a.getInt(R.styleable.PinView_viewType, VIEW_TYPE_RECTANGLE);
mPinItemCount = a.getInt(R.styleable.PinView_itemCount, DEFAULT_COUNT);
mPinItemSize = a.getDimensionPixelSize(R.styleable.PinView_itemSize,
res.getDimensionPixelOffset(R.dimen.pv_pin_view_item_size));
mPinItemHeight = mPinItemWidth = mPinItemSize;
if (a.hasValue(R.styleable.PinView_itemHeight)) {
mPinItemHeight = a.getDimensionPixelOffset(R.styleable.PinView_itemHeight,
res.getDimensionPixelOffset(R.dimen.pv_pin_view_item_size));
}
if (a.hasValue(R.styleable.PinView_itemWidth)) {
mPinItemWidth = a.getDimensionPixelOffset(R.styleable.PinView_itemWidth,
res.getDimensionPixelOffset(R.dimen.pv_pin_view_item_size));
}
mPinItemSpacing = a.getDimensionPixelOffset(R.styleable.PinView_itemSpacing,
res.getDimensionPixelOffset(R.dimen.pv_pin_view_item_spacing));
mPinItemRadius = a.getDimensionPixelOffset(R.styleable.PinView_itemRadius,
res.getDimensionPixelOffset(R.dimen.pv_pin_view_item_radius));
mLineWidth = a.getDimensionPixelOffset(R.styleable.PinView_borderWidth,
res.getDimensionPixelOffset(R.dimen.pv_pin_view_item_line_width));
mLineColor = a.getColorStateList(R.styleable.PinView_borderColor);
if (a.hasValue(R.styleable.PinView_lineWidth)) {
mLineWidth = a.getDimensionPixelOffset(R.styleable.PinView_lineWidth,
res.getDimensionPixelOffset(R.dimen.pv_pin_view_item_line_width));
}
if (a.hasValue(R.styleable.PinView_lineColor)) {
mLineColor = a.getColorStateList(R.styleable.PinView_lineColor);
}
a.recycle();
setMaxLength(mPinItemCount);
mPaint.setStrokeWidth(mLineWidth);
setupAnimator();
setCursorVisible(false);
setTextIsSelectable(false);
}
示例11: onDraw
import android.text.TextPaint; //導入方法依賴的package包/類
@Override
protected void onDraw(Canvas canvas) {
Canvas c = canvas;
if (mExternalSurface != null) {
try {
canvas.getClipBounds(r);
getLocationOnScreen(location);
r.offsetTo(location[0],location[1]);
c = mExternalSurface.lockCanvas(null);
c.save();
c.drawColor(Color.TRANSPARENT, PorterDuff.Mode.CLEAR);
c.clipRect(r);
c.translate(location[0],location[1]);
} catch (Exception ignored) {
}
}
TextPaint paint = getPaint();
int color = getCurrentTextColor();
paint.setStyle(Paint.Style.STROKE);
paint.setStrokeJoin(Paint.Join.MITER);
paint.setStrokeMiter(1.0f);
paint.setStrokeWidth(4.0f);
setTextColor(Color.BLACK);
super.onDraw(c);
paint.setStyle(Paint.Style.FILL);
setTextColor(color);
super.onDraw(c);
if (c != canvas) {
c.restore();
mExternalSurface.unlockCanvasAndPost(c);
}
}
示例12: updateDrawState
import android.text.TextPaint; //導入方法依賴的package包/類
@Override
public void updateDrawState(TextPaint tp) {
if (mDrawStroke) {
tp.setColor(mStrokeColor);
tp.setStrokeCap(Paint.Cap.ROUND);
tp.setStrokeWidth(mStrokeWidth);
tp.setStyle(Paint.Style.STROKE);
} else {
tp.setColor(mTextColor);
tp.setStyle(Paint.Style.FILL);
}
}
示例13: updateDrawState
import android.text.TextPaint; //導入方法依賴的package包/類
@Override
public void updateDrawState(TextPaint paint) {
paint.setStyle(Paint.Style.FILL);
Shader shader = new LinearGradient(0, 0, 0, paint.getTextSize() * colors.length, colors, null,
Shader.TileMode.MIRROR);
Matrix matrix = new Matrix();
matrix.setRotate(angle);
shader.setLocalMatrix(matrix);
paint.setShader(shader);
}
示例14: Settings
import android.text.TextPaint; //導入方法依賴的package包/類
public Settings(Slidr slidr) {
this.slidr = slidr;
paintIndicator = new Paint();
paintIndicator.setAntiAlias(true);
paintIndicator.setStrokeWidth(2);
paintBar = new Paint();
paintBar.setAntiAlias(true);
paintBar.setStrokeWidth(2);
paintBar.setColor(colorBackground);
paintStep = new Paint();
paintStep.setAntiAlias(true);
paintStep.setStrokeWidth(5);
paintStep.setColor(colorStoppover);
paintTextTop = new TextPaint();
paintTextTop.setAntiAlias(true);
paintTextTop.setStyle(Paint.Style.FILL);
paintTextTop.setColor(textColor);
paintTextTop.setTextSize(textTopSize);
paintTextBottom = new TextPaint();
paintTextBottom.setAntiAlias(true);
paintTextBottom.setStyle(Paint.Style.FILL);
paintTextBottom.setColor(textColor);
paintTextBottom.setTextSize(textBottomSize);
paintBubbleTextCurrent = new TextPaint();
paintBubbleTextCurrent.setAntiAlias(true);
paintBubbleTextCurrent.setStyle(Paint.Style.FILL);
paintBubbleTextCurrent.setColor(Color.WHITE);
paintBubbleTextCurrent.setStrokeWidth(2);
paintBubbleTextCurrent.setTextSize(dpToPx(textSizeBubbleCurrent));
paintBubble = new Paint();
paintBubble.setAntiAlias(true);
paintBubble.setStrokeWidth(3);
}
示例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);
}
};
}
}