本文整理汇总了Java中android.graphics.Paint.setFakeBoldText方法的典型用法代码示例。如果您正苦于以下问题:Java Paint.setFakeBoldText方法的具体用法?Java Paint.setFakeBoldText怎么用?Java Paint.setFakeBoldText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.graphics.Paint
的用法示例。
在下文中一共展示了Paint.setFakeBoldText方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: apply
import android.graphics.Paint; //导入方法依赖的package包/类
private void apply(Paint paint, Typeface tf) {
int oldStyle;
Typeface old = paint.getTypeface();
if (old == null) {
oldStyle = 0;
} else {
oldStyle = old.getStyle();
}
int fake = oldStyle & ~tf.getStyle();
if ((fake & Typeface.BOLD) != 0) {
paint.setFakeBoldText(true);
}
if ((fake & Typeface.ITALIC) != 0) {
paint.setTextSkewX(-0.25f);
}
paint.getShader();
paint.setTypeface(tf);
}
示例2: init
import android.graphics.Paint; //导入方法依赖的package包/类
private void init() {
ateKey = Helper.getATEKey(getContext());
accentColor = Config.accentColor(getContext(), ateKey);
textPaint = new Paint();
textPaint.setColor(labelColor);
textPaint.setStyle(Paint.Style.FILL);
textPaint.setTextSize(labelSize);
textPaint.setFakeBoldText(true);
textPaint.setTextAlign(Paint.Align.CENTER);
circlePaint = new Paint();
circlePaint.setColor(progressSecondaryColor);
circlePaint.setStrokeWidth(progressSecondaryStrokeWidth);
circlePaint.setStyle(Paint.Style.FILL);
circlePaint2 = new Paint();
circlePaint2.setColor(accentColor);
circlePaint2.setTextAlign(Paint.Align.CENTER);
circlePaint2.setStrokeWidth(progressPrimaryStrokeWidth);
circlePaint2.setStyle(Paint.Style.FILL);
linePaint = new Paint();
linePaint.setColor(indicatorColor);
linePaint.setStrokeWidth(indicatorWidth);
oval = new RectF();
}
示例3: applyCustomTypeFace
import android.graphics.Paint; //导入方法依赖的package包/类
private void applyCustomTypeFace(Paint paint, FontFamily tf) {
paint.setAntiAlias(true);
paint.setTypeface(tf.getDefaultTypeface());
if (bold) {
if (tf.isFakeBold()) {
paint.setFakeBoldText(true);
} else {
paint.setTypeface(tf.getBoldTypeface());
}
}
if (italic) {
if (tf.isFakeItalic()) {
paint.setTextSkewX(-0.25f);
} else {
paint.setTypeface(tf.getItalicTypeface());
}
}
if (bold && italic && tf.getBoldItalicTypeface() != null) {
paint.setTypeface(tf.getBoldItalicTypeface());
}
}
示例4: applyCustomTypeFace
import android.graphics.Paint; //导入方法依赖的package包/类
private static void applyCustomTypeFace(Paint paint, Typeface tf) {
int oldStyle;
Typeface old = paint.getTypeface();
if (old == null) {
oldStyle = 0;
} else {
oldStyle = old.getStyle();
}
int fake = oldStyle & ~tf.getStyle();
if ((fake & Typeface.BOLD) != 0) {
paint.setFakeBoldText(true);
}
if ((fake & Typeface.ITALIC) != 0) {
paint.setTextSkewX(-0.25f);
}
paint.setTypeface(tf);
}
示例5: apply
import android.graphics.Paint; //导入方法依赖的package包/类
private void apply(final Paint paint)
{
final Typeface oldTypeface = paint.getTypeface();
final int oldStyle = oldTypeface != null ? oldTypeface.getStyle() : 0;
final int fakeStyle = oldStyle & ~typeface.getStyle();
if ((fakeStyle & Typeface.BOLD) != 0)
{
paint.setFakeBoldText(true);
}
if ((fakeStyle & Typeface.ITALIC) != 0)
{
paint.setTextSkewX(-0.25f);
}
paint.setTypeface(typeface);
}
示例6: initPaintTools
import android.graphics.Paint; //导入方法依赖的package包/类
private void initPaintTools() {
satValPaint = new Paint();
satValTrackerPaint = new Paint();
hueAlphaTrackerPaint = new Paint();
alphaPaint = new Paint();
alphaTextPaint = new Paint();
borderPaint = new Paint();
satValTrackerPaint.setStyle(Style.STROKE);
satValTrackerPaint.setStrokeWidth(DrawingUtils.dpToPx(getContext(), 2));
satValTrackerPaint.setAntiAlias(true);
hueAlphaTrackerPaint.setColor(sliderTrackerColor);
hueAlphaTrackerPaint.setStyle(Style.STROKE);
hueAlphaTrackerPaint.setStrokeWidth(DrawingUtils.dpToPx(getContext(), 2));
hueAlphaTrackerPaint.setAntiAlias(true);
alphaTextPaint.setColor(0xff1c1c1c);
alphaTextPaint.setTextSize(DrawingUtils.dpToPx(getContext(), 14));
alphaTextPaint.setAntiAlias(true);
alphaTextPaint.setTextAlign(Align.CENTER);
alphaTextPaint.setFakeBoldText(true);
}
示例7: updatePaintTypeface
import android.graphics.Paint; //导入方法依赖的package包/类
/**
* Updates typeface setting for the given <var>paint</var> to the specified one.
*
* @param paint The paint to be updated.
* @param typeface The desired typeface. May be {@code null} to resolve instance of typeface
* from the specified style.
* @param style The desired text style used to resolve proper instance of typeface.
* @return {@code True} if paint's typeface setting has changed, {@code false} otherwise.
* @see Paint#setTypeface(Typeface)
*/
public static boolean updatePaintTypeface(@NonNull Paint paint, @Nullable Typeface typeface, @TextStyle int style) {
if (style > 0) {
if (typeface == null) {
typeface = Typeface.defaultFromStyle(style);
} else {
typeface = Typeface.create(typeface, style);
}
final int typefaceStyle = typeface != null ? typeface.getStyle() : 0;
final int need = style & ~typefaceStyle;
paint.setFakeBoldText((need & Typeface.BOLD) != 0);
paint.setTextSkewX((need & Typeface.ITALIC) != 0 ? -0.25f : 0);
paint.setTypeface(typeface);
} else {
paint.setFakeBoldText(false);
paint.setTextSkewX(0);
paint.setTypeface(typeface);
}
return true;
}
示例8: drawNumbers
import android.graphics.Paint; //导入方法依赖的package包/类
/**
* Function to draw number in the bitmap
*
* @param number Number to draw
* @return the new bitmap after draw
*/
public Bitmap drawNumbers(String number) {
float fontAndPadding = getResources().getDimension(R.dimen.draw_number);
Paint paint = new Paint();
paint.setTextSize(fontAndPadding);
paint.setColor(Color.WHITE);
paint.setAntiAlias(true);
paint.setFilterBitmap(true);
paint.setDither(true);
paint.setFakeBoldText(true);
Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.ic_repeat);
Bitmap mutableBitmap = bitmap.copy(Bitmap.Config.ARGB_8888, true);
Canvas canvas = new Canvas(mutableBitmap);
canvas.drawText(number, bitmap.getWidth() - fontAndPadding, fontAndPadding, paint);
return mutableBitmap;
}
示例9: applyTypeface
import android.graphics.Paint; //导入方法依赖的package包/类
public static void applyTypeface(Context context, Paint v) {
if (v.getTypeface() == null) {
v.setTypeface(getNormal(context));
return;
}
switch (v.getTypeface().getStyle()) {
case Typeface.BOLD:
v.setTypeface(getNormal(context));
v.setFakeBoldText(true);
break;
default:
v.setTypeface(getNormal(context));
break;
case Typeface.ITALIC:
v.setTypeface(getNormal(context));
v.setTextSkewX(-0.25f);
break;
case Typeface.BOLD_ITALIC:
v.setTypeface(getNormal(context));
v.setFakeBoldText(true);
v.setTextSkewX(-0.25f);
break;
}
}
示例10: addWaterMark
import android.graphics.Paint; //导入方法依赖的package包/类
/**
* @param src Original image
* @param context needed to fetch resources
* @return new bitmap resource containing the watermark
*/
public static Bitmap addWaterMark(Bitmap src, Context context) {
int height = src.getHeight() + UiUtils.dpToPx(32 + 8);
int width = src.getWidth();
Bitmap result = Bitmap.createBitmap(width, height, src.getConfig());
Canvas canvas = new Canvas(result);
canvas.drawBitmap(src, 0, 0, null);
int darkGrey = context.getResources().getColor(R.color.grey_900);
Bitmap appIcon = BitmapFactory.decodeResource(context.getResources(), R.mipmap.ic_launcher);
appIcon = Bitmap.createScaledBitmap(appIcon, UiUtils.dpToPx(32), UiUtils.dpToPx(32), false);
Paint backgroundPaint = new Paint();
backgroundPaint.setColor(Color.WHITE);
backgroundPaint.setAntiAlias(true);
backgroundPaint.setShadowLayer(6, 2, 2, darkGrey);
Paint textPaint = new Paint();
textPaint.setColor(darkGrey);
textPaint.setAntiAlias(true);
textPaint.setTextSize(UiUtils.dpToPx(16));
textPaint.setFakeBoldText(true);
Paint appIconPaint = new Paint();
appIconPaint.setAntiAlias(true);
appIconPaint.setFilterBitmap(true);
appIconPaint.setDither(true);
float srcHeight = src.getHeight();
int _4dp = UiUtils.dpToPx(4);
String watermarkText = context.getString(R.string.app_name);
Paint.FontMetrics fontMetrics = textPaint.getFontMetrics();
float watermarkTextY = srcHeight + (height - srcHeight) / 2f + (fontMetrics.descent - fontMetrics.ascent) / 2f;
canvas.drawRect(0, srcHeight, width, height, backgroundPaint);
canvas.drawText(watermarkText, (_4dp) * 2 + appIcon.getWidth(), watermarkTextY, textPaint);
canvas.drawBitmap(appIcon, _4dp, _4dp + srcHeight, appIconPaint);
appIcon.recycle();
src.recycle();
return result;
}
示例11: flagDate
import android.graphics.Paint; //导入方法依赖的package包/类
private void flagDate(Canvas canvas, String flag, @ColorInt int clr, int y, int x) {
Paint flagP = new Paint();
flagP.setAntiAlias(true);
float flagTS = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, 12, getResources().getDisplayMetrics());
flagP.setTextSize(flagTS);
flagP.setStyle(Style.FILL);
flagP.setColor(clr);
flagP.setTextAlign(Align.CENTER);
flagP.setFakeBoldText(false);
canvas.drawText(flag, x, y - DAY_ROW_MARGIN - DAY_NUM_HALF_WIDTH, flagP);
}
示例12: initSetting
import android.graphics.Paint; //导入方法依赖的package包/类
/******************
* common
******************/
private void initSetting(Context context, AttributeSet attrs) {
mOnTouchingLetterChangeListener = getDummyListener();
mNavigators = new ArrayList<>(0);
mFocusIndex = -1;
TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.IndexBar);
float textSize = typedArray.getDimension(R.styleable.IndexBar_letterSize, 8);
int letterColor = typedArray.getColor(R.styleable.IndexBar_letterColor,
ContextCompat.getColor(getContext(), android.R.color.white));
mLetterSpacingExtra = typedArray.getFloat(R.styleable.IndexBar_letterSpacingExtra, 1.4f);
int focusLetterColor = typedArray.getColor(R.styleable.IndexBar_focusLetterColor,
ContextCompat.getColor(getContext(), android.R.color.white));
typedArray.recycle();
mPaint = new Paint();
mPaint.setTypeface(Typeface.DEFAULT_BOLD);
mPaint.setAntiAlias(true);
mPaint.setColor(letterColor);
mPaint.setTextSize(textSize);
mFocusPaint = new Paint();
mFocusPaint.setTypeface(Typeface.DEFAULT_BOLD);
mFocusPaint.setAntiAlias(true);
mFocusPaint.setFakeBoldText(true);
mFocusPaint.setTextSize(textSize);
mFocusPaint.setColor(focusLetterColor);
}
示例13: TextDrawable
import android.graphics.Paint; //导入方法依赖的package包/类
private TextDrawable(Builder builder) {
super(builder.shape);
// shape properties
shape = builder.shape;
height = builder.height;
width = builder.width;
radius = builder.radius;
// text and color
text = builder.toUpperCase ? builder.text.toUpperCase() : builder.text;
color = builder.color;
// text paint settings
fontSize = builder.fontSize;
textPaint = new Paint();
textPaint.setColor(builder.textColor);
textPaint.setAntiAlias(true);
textPaint.setFakeBoldText(builder.isBold);
textPaint.setStyle(Paint.Style.FILL);
textPaint.setTypeface(builder.font);
textPaint.setTextAlign(Paint.Align.CENTER);
textPaint.setStrokeWidth(builder.borderThickness);
// border paint settings
borderThickness = builder.borderThickness;
borderPaint = new Paint();
borderPaint.setColor(getDarkerShade(color));
borderPaint.setStyle(Paint.Style.STROKE);
borderPaint.setStrokeWidth(borderThickness);
// drawable paint color
Paint paint = getPaint();
paint.setColor(color);
}
示例14: apply
import android.graphics.Paint; //导入方法依赖的package包/类
private void apply(final Paint paint) {
final Typeface oldTypeface = paint.getTypeface();
final int oldStyle = oldTypeface != null ? oldTypeface.getStyle() : 0;
final int fakeStyle = oldStyle & ~typeface.getStyle();
if ((fakeStyle & Typeface.BOLD) != 0) {
paint.setFakeBoldText(true);
}
if ((fakeStyle & Typeface.ITALIC) != 0) {
paint.setTextSkewX(-0.25f);
}
paint.setTypeface(typeface);
}
示例15: initPaintTools
import android.graphics.Paint; //导入方法依赖的package包/类
private void initPaintTools(){
mSatValPaint = new Paint();
mSatValTrackerPaint = new Paint();
mHuePaint = new Paint();
mHueTrackerPaint = new Paint();
mAlphaPaint = new Paint();
mAlphaTextPaint = new Paint();
mBorderPaint = new Paint();
mSatValTrackerPaint.setStyle(Style.STROKE);
mSatValTrackerPaint.setStrokeWidth(2f * mDensity);
mSatValTrackerPaint.setAntiAlias(true);
mHueTrackerPaint.setColor(mSliderTrackerColor);
mHueTrackerPaint.setStyle(Style.STROKE);
mHueTrackerPaint.setStrokeWidth(2f * mDensity);
mHueTrackerPaint.setAntiAlias(true);
mAlphaTextPaint.setColor(0xff1c1c1c);
mAlphaTextPaint.setTextSize(14f * mDensity);
mAlphaTextPaint.setAntiAlias(true);
mAlphaTextPaint.setTextAlign(Align.CENTER);
mAlphaTextPaint.setFakeBoldText(true);
}