Java Code Examples for android.text.TextPaint#setFlags()
The following examples show how to use
android.text.TextPaint#setFlags() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TextStyleSpan.java From Telegram with GNU General Public License v2.0 | 6 votes |
public void applyStyle(TextPaint p) { Typeface typeface = getTypeface(); if (typeface != null) { p.setTypeface(typeface); } if ((flags & FLAG_STYLE_UNDERLINE) != 0) { p.setFlags(p.getFlags() | Paint.UNDERLINE_TEXT_FLAG); } else { p.setFlags(p.getFlags() &~ Paint.UNDERLINE_TEXT_FLAG); } if ((flags & FLAG_STYLE_STRIKE) != 0) { p.setFlags(p.getFlags() | Paint.STRIKE_THRU_TEXT_FLAG); } else { p.setFlags(p.getFlags() &~ Paint.STRIKE_THRU_TEXT_FLAG); } }
Example 2
Source File: TextStyleSpan.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
@Override public void updateMeasureState(TextPaint p) { if (textSize != 0) { p.setTextSize(textSize); } p.setFlags(p.getFlags() | Paint.SUBPIXEL_TEXT_FLAG); style.applyStyle(p); }
Example 3
Source File: TextPaintUrlSpan.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
@Override public void updateDrawState(TextPaint p) { if (textPaint != null) { p.setColor(textPaint.getColor()); p.setTypeface(textPaint.getTypeface()); p.setFlags(textPaint.getFlags()); p.setTextSize(textPaint.getTextSize()); p.baselineShift = textPaint.baselineShift; p.bgColor = textPaint.bgColor; } }
Example 4
Source File: TextPaintUrlSpan.java From Telegram with GNU General Public License v2.0 | 5 votes |
@Override public void updateMeasureState(TextPaint p) { if (textPaint != null) { p.setColor(textPaint.getColor()); p.setTypeface(textPaint.getTypeface()); p.setFlags(textPaint.getFlags()); p.setTextSize(textPaint.getTextSize()); p.baselineShift = textPaint.baselineShift; p.bgColor = textPaint.bgColor; } }
Example 5
Source File: TypefaceSpan.java From FaceT with Mozilla Public License 2.0 | 5 votes |
@Override public void updateMeasureState(TextPaint p) { p.setTypeface(mTypeface); // Note: This flag is required for proper typeface rendering p.setFlags(p.getFlags() | Paint.SUBPIXEL_TEXT_FLAG); }
Example 6
Source File: TypefaceSpan.java From actionbarextras with MIT License | 5 votes |
@Override public void updateMeasureState(TextPaint p) { p.setTypeface(mTypeface); // Note: This flag is required for proper typeface rendering p.setFlags(p.getFlags() | Paint.SUBPIXEL_TEXT_FLAG); }
Example 7
Source File: TextPaintMarkSpan.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
@Override public void updateDrawState(TextPaint p) { if (textPaint != null) { p.setColor(textPaint.getColor()); p.setTypeface(textPaint.getTypeface()); p.setFlags(textPaint.getFlags()); p.setTextSize(textPaint.getTextSize()); p.baselineShift = textPaint.baselineShift; p.bgColor = textPaint.bgColor; } }
Example 8
Source File: TypefaceSpan.java From android-atleap with Apache License 2.0 | 5 votes |
@Override public void updateMeasureState(TextPaint p) { p.setTypeface(mTypeface); // Note: This flag is required for proper typeface rendering p.setFlags(p.getFlags() | Paint.SUBPIXEL_TEXT_FLAG); }
Example 9
Source File: TypefaceSpan.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
@Override public void updateDrawState(TextPaint tp) { if (typeface != null) { tp.setTypeface(typeface); } if (textSize != 0) { tp.setTextSize(textSize); } if (color != 0) { tp.setColor(color); } tp.setFlags(tp.getFlags() | Paint.SUBPIXEL_TEXT_FLAG); }
Example 10
Source File: TextPaintSpan.java From Telegram with GNU General Public License v2.0 | 5 votes |
@Override public void updateDrawState(TextPaint p) { p.setColor(textPaint.getColor()); p.setTypeface(textPaint.getTypeface()); p.setFlags(textPaint.getFlags()); p.setTextSize(textPaint.getTextSize()); p.baselineShift = textPaint.baselineShift; p.bgColor = textPaint.bgColor; }
Example 11
Source File: TextPaintMarkSpan.java From Telegram with GNU General Public License v2.0 | 5 votes |
@Override public void updateDrawState(TextPaint p) { if (textPaint != null) { p.setColor(textPaint.getColor()); p.setTypeface(textPaint.getTypeface()); p.setFlags(textPaint.getFlags()); p.setTextSize(textPaint.getTextSize()); p.baselineShift = textPaint.baselineShift; p.bgColor = textPaint.bgColor; } }
Example 12
Source File: TypefaceSpan.java From android-atleap with Apache License 2.0 | 5 votes |
@Override public void updateDrawState(TextPaint tp) { tp.setTypeface(mTypeface); // Note: This flag is required for proper typeface rendering tp.setFlags(tp.getFlags() | Paint.SUBPIXEL_TEXT_FLAG); }
Example 13
Source File: TypefaceSpan.java From Telegram with GNU General Public License v2.0 | 5 votes |
@Override public void updateDrawState(TextPaint tp) { if (typeface != null) { tp.setTypeface(typeface); } if (textSize != 0) { tp.setTextSize(textSize); } if (color != 0) { tp.setColor(color); } tp.setFlags(tp.getFlags() | Paint.SUBPIXEL_TEXT_FLAG); }
Example 14
Source File: TypefaceSpan.java From Telegram with GNU General Public License v2.0 | 5 votes |
@Override public void updateMeasureState(TextPaint p) { if (typeface != null) { p.setTypeface(typeface); } if (textSize != 0) { p.setTextSize(textSize); } p.setFlags(p.getFlags() | Paint.SUBPIXEL_TEXT_FLAG); }
Example 15
Source File: Clock.java From Clock-view with Apache License 2.0 | 4 votes |
private void drawStopWatch(Canvas canvas) { if (showBorder) { drawCustomBorder(canvas); } if (clockBackground != null) { Paint paint = new Paint(); paint.setAntiAlias(true); Bitmap bitmap = ((BitmapDrawable) clockBackground).getBitmap(); RectF rectF = new RectF(centerX - radius, centerY - radius, centerX + radius, centerY + radius); Bitmap output = Bitmap.createBitmap(size, size, Bitmap.Config.ARGB_8888); Canvas tCanvas = new Canvas(output); switch (borderStyle) { case rectangle: tCanvas.drawRect(defaultRectF, paint); break; case circle: tCanvas.drawCircle(centerX, centerY, radius, paint); break; case rounded_rectangle: float rx = radius - (radius * (100 - borderRadiusRx)) / 100; float ry = radius - (radius * (100 - borderRadiusRy)) / 100; tCanvas.drawRoundRect(defaultRectF, rx, ry, paint); break; } paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN)); tCanvas.drawBitmap(bitmap, null, rectF, paint); canvas.drawBitmap(output, null, rectF, new Paint()); } TextPaint textPaint = new TextPaint(); textPaint.setFlags(Paint.ANTI_ALIAS_FLAG); textPaint.setAntiAlias(true); textPaint.setTextSize(size * 0.25f); textPaint.setColor(this.valuesColor); textPaint.setTypeface(this.valuesFont); String stopwatchValue = String.format(Locale.getDefault(), "%02d", mMinutes) + ":" + String.format(Locale.getDefault(), "%02d", mSeconds); SpannableStringBuilder spannableString = new SpannableStringBuilder(stopwatchValue); StaticLayout layout = new StaticLayout(spannableString, textPaint, canvas.getWidth(), Layout.Alignment.ALIGN_CENTER, 1, 1, true); canvas.translate(centerX - layout.getWidth() / 2, centerY - layout.getHeight() / 2); layout.draw(canvas); }
Example 16
Source File: Clock.java From Clock-view with Apache License 2.0 | 4 votes |
private void drawHoursValues(Canvas canvas) { if (!showHoursValues) return; Rect rect = new Rect(); TextPaint textPaint = new TextPaint(); textPaint.setFlags(Paint.ANTI_ALIAS_FLAG); textPaint.setAntiAlias(true); textPaint.setColor(this.valuesColor); textPaint.setTypeface(this.valuesFont); textPaint.setTextSize(size * DEFAULT_HOURS_VALUES_TEXT_SIZE); float degreeSpace = 0f; if (showDegrees) degreeSpace = DEFAULT_DEGREE_STROKE_WIDTH + 0.06f; int rText = (int) (centerX - (size * DEFAULT_HOURS_VALUES_TEXT_SIZE) - (size * degreeSpace)); for (int i = FULL_ANGLE; i > 0; i = i - valueStep.getId()) { int value = i / 30; String formatted; switch (valueType) { case roman: formatted = ClockUtils.toRoman(value); break; case arabic: formatted = ClockUtils.toArabic(value); break; default: formatted = String.format(Locale.getDefault(), "%02d", value); break; } if (valueDisposition.getId() == 0) { if ((i % REGULAR_ANGLE) == 0) { textPaint.setTextSize(size * DEFAULT_HOURS_VALUES_TEXT_SIZE); textPaint.setAlpha(FULL_ALPHA); } else { textPaint.setTextSize(size * (DEFAULT_HOURS_VALUES_TEXT_SIZE - 0.03f)); textPaint.setAlpha(CUSTOM_ALPHA); } } else { textPaint.setTextSize(size * DEFAULT_HOURS_VALUES_TEXT_SIZE); textPaint.setAlpha(FULL_ALPHA); } int textX = (int) (centerX + rText * Math.cos(Math.toRadians(REGULAR_ANGLE - i))); int textY = (int) (centerX - rText * Math.sin(Math.toRadians(REGULAR_ANGLE - i))); textPaint.getTextBounds(formatted, 0, formatted.length(), rect); canvas.drawText(formatted, textX - rect.width() / formatted.length(), textY + rect.height() / formatted.length(), textPaint); } }
Example 17
Source File: ActionBarHelper.java From FontsManager with Eclipse Public License 1.0 | 4 votes |
@Override public void updateDrawState(TextPaint tp) { tp.setTypeface(typeface); tp.setFlags(tp.getFlags() | Paint.SUBPIXEL_TEXT_FLAG); }
Example 18
Source File: TypefaceHelper.java From android-typeface-helper with Apache License 2.0 | 4 votes |
@Override public void updateDrawState(TextPaint tp) { tp.setTypeface(typeface); tp.setFlags(tp.getFlags() | Paint.SUBPIXEL_TEXT_FLAG); }
Example 19
Source File: CustomTypefaceSpan.java From dhis2-android-datacapture with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Override public void updateDrawState(TextPaint paint) { paint.setTypeface(mTypeface); paint.setFlags(paint.getFlags() | Paint.SUBPIXEL_TEXT_FLAG); }
Example 20
Source File: BootstrapDrawableFactory.java From Android-Bootstrap with MIT License | 4 votes |
public static Drawable createBadgeDrawable(Context context, BootstrapBrand brand, int width, int height, String badgeText, boolean insideAnObject) { if (badgeText == null) { return null; } else { Paint badgePaint = new Paint(); Rect canvasBounds = new Rect(); TextPaint badgeTextPaint = new TextPaint(); badgePaint.setFlags(Paint.ANTI_ALIAS_FLAG); badgeTextPaint.setFlags(Paint.ANTI_ALIAS_FLAG); badgeTextPaint.setTextAlign(Paint.Align.CENTER); badgeTextPaint.setTextSize((float) (height * 0.7)); if (insideAnObject) { badgePaint.setColor(brand.defaultTextColor(context)); badgeTextPaint.setColor(brand.defaultFill(context)); } else { badgePaint.setColor(brand.defaultFill(context)); badgeTextPaint.setColor(brand.defaultTextColor(context)); } int rectLength = (int) badgeTextPaint.measureText(badgeText); Bitmap canvasBitmap = Bitmap.createBitmap(width + rectLength, height, Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(canvasBitmap); canvas.getClipBounds(canvasBounds); int firstCircleDx = canvasBounds.left + canvasBounds.height() / 2; int circleDy = canvasBounds.height() / 2; int circleRadius = canvasBounds.height() / 2; int secondCircleDx = firstCircleDx + rectLength; Rect rect = new Rect(); rect.left = firstCircleDx; rect.top = 0; rect.right = rect.left + rectLength; rect.bottom = canvasBounds.height(); canvas.drawCircle(firstCircleDx, circleDy, circleRadius, badgePaint); canvas.drawRect(rect, badgePaint); canvas.drawCircle(secondCircleDx, circleDy, circleRadius, badgePaint); canvas.drawText(badgeText, canvasBounds.width() / 2, canvasBounds.height() / 2 - ((badgeTextPaint.descent() + badgeTextPaint.ascent()) / 2), badgeTextPaint); return new BitmapDrawable(context.getResources(), canvasBitmap); } }