本文整理汇总了Java中android.graphics.Paint.SUBPIXEL_TEXT_FLAG属性的典型用法代码示例。如果您正苦于以下问题:Java Paint.SUBPIXEL_TEXT_FLAG属性的具体用法?Java Paint.SUBPIXEL_TEXT_FLAG怎么用?Java Paint.SUBPIXEL_TEXT_FLAG使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类android.graphics.Paint
的用法示例。
在下文中一共展示了Paint.SUBPIXEL_TEXT_FLAG属性的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: GifBadge
GifBadge(Context context) {
if (bitmap == null) {
final DisplayMetrics dm = context.getResources().getDisplayMetrics();
final float density = dm.density;
final float scaledDensity = dm.scaledDensity;
final TextPaint textPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG | Paint
.SUBPIXEL_TEXT_FLAG);
textPaint.setTypeface(Typeface.create(TYPEFACE, TYPEFACE_STYLE));
textPaint.setTextSize(TEXT_SIZE * scaledDensity);
final float padding = PADDING * density;
final float cornerRadius = CORNER_RADIUS * density;
final Rect textBounds = new Rect();
textPaint.getTextBounds(GIF, 0, GIF.length(), textBounds);
height = (int) (padding + textBounds.height() + padding);
width = (int) (padding + textBounds.width() + padding);
bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
bitmap.setHasAlpha(true);
final Canvas canvas = new Canvas(bitmap);
final Paint backgroundPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
backgroundPaint.setColor(BACKGROUND_COLOR);
canvas.drawRoundRect(0, 0, width, height, cornerRadius, cornerRadius,
backgroundPaint);
// punch out the word 'GIF', leaving transparency
textPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.CLEAR));
canvas.drawText(GIF, padding, height - padding, textPaint);
}
paint = new Paint();
}
示例2: QMUICollapsingTextHelper
public QMUICollapsingTextHelper(View view) {
mView = view;
mTextPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);
mCollapsedBounds = new Rect();
mExpandedBounds = new Rect();
mCurrentBounds = new RectF();
}
示例3: CollapsingTextHelper
public CollapsingTextHelper(View view) {
mView = view;
mTextPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);
mCollapsedBounds = new Rect();
mExpandedBounds = new Rect();
mCurrentBounds = new RectF();
}
示例4: StaticLabelTextInputLayout
public StaticLabelTextInputLayout(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
mTextPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);
mTextPaint.setTypeface(getTypeface());
mTextPaint.setTextSize(getResources().getDimensionPixelSize(R.dimen.abc_text_size_caption_material));
StyledAttributesHelper ta = StyledAttributesHelper.obtainStyledAttributes(context,
new int[] { android.R.attr.textColorHint });
mTextColorUnfocused = ta.getColor(android.R.attr.textColorHint, 0);
ta.recycle();
mTextColorFocused = ThemeHelper.getAccentColor(context);
mTextPaint.setColor(mTextColorUnfocused);
}
示例5: LabelLayout
public LabelLayout(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
setWillNotDraw(false);
setAddStatesFromChildren(true);
mInputFrame = new FrameLayout(context);
mInputFrame.setAddStatesFromChildren(true);
super.addView(mInputFrame, -1, generateDefaultLayoutParams());
mTextPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);
mTextPaint.setTypeface(Typeface.DEFAULT);// getTypeface());
mTextSizeCollapsed = getResources().getDimensionPixelSize(R.dimen.abc_text_size_caption_material);
mTextSizeExpanded = getResources().getDimensionPixelSize(R.dimen.abc_text_size_medium_material);
mTextPaint.setTextSize(mTextSizeCollapsed);
StyledAttributesHelper ta = StyledAttributesHelper.obtainStyledAttributes(context, attrs,
new int[] { R.attr.doNotExpand, android.R.attr.hint, android.R.attr.textColorHint });
try {
mDoNotExpand = ta.getBoolean(R.attr.doNotExpand, false);
mHint = ta.getString(android.R.attr.hint);
mTextColorUnfocused = ta.getColorStateList(android.R.attr.textColorHint);
} finally {
ta.recycle();
}
mTextColorFocused = ThemeHelper.getAccentColor(context);
mTextPaint.setColor(mTextColorUnfocused.getColorForState(getDrawableState(), mTextColorUnfocused.getDefaultColor()));
mAnimator = ValueAnimator.ofFloat(0.f, 1.f);
mAnimator.setInterpolator(new LinearInterpolator());
mAnimator.setDuration(200);
mAnimator.addUpdateListener((ValueAnimator animation) -> {
mAnimState = (float) animation.getAnimatedValue();
invalidate();
});
updateTopMargin();
updateTextPositions();
}
示例6: setTypeface
public final void setTypeface(TextView target, Typeface t) {
if (t == null) return;
int flags = target.getPaintFlags() | Paint.SUBPIXEL_TEXT_FLAG;
target.setPaintFlags(flags);
target.setTypeface(t);
}