当前位置: 首页>>代码示例>>Java>>正文


Java TextPaint.setTypeface方法代码示例

本文整理汇总了Java中android.text.TextPaint.setTypeface方法的典型用法代码示例。如果您正苦于以下问题:Java TextPaint.setTypeface方法的具体用法?Java TextPaint.setTypeface怎么用?Java TextPaint.setTypeface使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.text.TextPaint的用法示例。


在下文中一共展示了TextPaint.setTypeface方法的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);
}
 
开发者ID:coding-dream,项目名称:TPlayer,代码行数:17,代码来源:OutlineTextView.java

示例2: initPaintObjects

import android.text.TextPaint; //导入方法依赖的package包/类
private void initPaintObjects() {

        int labelTextSize = getResources().getDimensionPixelSize(R.dimen.label_text_size);

        paint = new Paint(Paint.ANTI_ALIAS_FLAG);

        textPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG);
        textPaint.setTextSize(labelTextSize);
        if (typeface != null) {
            textPaint.setTypeface(typeface);
        }
        textPaint.setColor(baseColor);
        baseAlpha = textPaint.getAlpha();

        selectorPath = new Path();
        selectorPath.setFillType(Path.FillType.EVEN_ODD);

        selectorPoints = new Point[3];
        for (int i = 0; i < 3; i++) {
            selectorPoints[i] = new Point();
        }
    }
 
开发者ID:mityung,项目名称:XERUNG,代码行数:23,代码来源:MaterialSpinner.java

示例3: updateDrawState

import android.text.TextPaint; //导入方法依赖的package包/类
@Override
public void updateDrawState(TextPaint tp) {
    if (mTypeface != null) {
        tp.setTypeface(mTypeface);
    }
    if (textSize != 0) {
        tp.setTextSize(textSize);
    }
    if (color != 0) {
        tp.setColor(color);
    }
    tp.setFlags(tp.getFlags() | Paint.SUBPIXEL_TEXT_FLAG);
}
 
开发者ID:pooyafaroka,项目名称:PlusGram,代码行数:14,代码来源:TypefaceSpan.java

示例4: LabelLayout

import android.text.TextPaint; //导入方法依赖的package包/类
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();
}
 
开发者ID:MCMrARM,项目名称:revolution-irc,代码行数:40,代码来源:LabelLayout.java

示例5: updateMeasureState

import android.text.TextPaint; //导入方法依赖的package包/类
@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);
}
 
开发者ID:AndroidLiba,项目名称:asset-font-views,代码行数:8,代码来源:AssetFontSpan.java

示例6: updateDrawState

import android.text.TextPaint; //导入方法依赖的package包/类
@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);
}
 
开发者ID:djuelg,项目名称:Neuronizer,代码行数:8,代码来源:TypefaceSpan.java

示例7: CustomHintDialogCell

import android.text.TextPaint; //导入方法依赖的package包/类
public CustomHintDialogCell(Context context) {
    super(context);
    setBackgroundResource(R.drawable.list_selector);

    imageView = new BackupImageView(context);
    imageView.setRoundRadius(AndroidUtilities.dp(27));
    addView(imageView, LayoutHelper.createFrame(43, 43, Gravity.TOP | Gravity.CENTER_HORIZONTAL, 0, 7, 0, 0));

    nameTextView = new TextView(context);
    nameTextView.setTextColor(0xff212121);
    nameTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 9);
    nameTextView.setMaxLines(2);
    nameTextView.setGravity(Gravity.TOP | Gravity.CENTER_HORIZONTAL);
    nameTextView.setLines(2);
    nameTextView.setEllipsize(TextUtils.TruncateAt.END);
    addView(nameTextView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.LEFT | Gravity.TOP, 6, 64, 6, 0));

    if (countDrawable == null) {
        countDrawable = getResources().getDrawable(R.drawable.dialogs_badge);
        countDrawableGrey = getResources().getDrawable(R.drawable.dialogs_badge2);

        countPaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG);
        countPaint.setColor(0xffffffff);
        countPaint.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
    }
    countPaint.setTextSize(AndroidUtilities.dp(11));
}
 
开发者ID:pooyafaroka,项目名称:PlusGram,代码行数:28,代码来源:CustomHintDialogCell.java

示例8: updateMeasureState

import android.text.TextPaint; //导入方法依赖的package包/类
@Override
public void updateMeasureState(TextPaint p) {
    if (mTypeface != null) {
        p.setTypeface(mTypeface);
    }
    if (textSize != 0) {
        p.setTextSize(textSize);
    }
    p.setFlags(p.getFlags() | Paint.SUBPIXEL_TEXT_FLAG);
}
 
开发者ID:MLNO,项目名称:airgram,代码行数:11,代码来源:TypefaceSpan.java

示例9: StaticLabelTextInputLayout

import android.text.TextPaint; //导入方法依赖的package包/类
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);
}
 
开发者ID:MCMrARM,项目名称:revolution-irc,代码行数:14,代码来源:StaticLabelTextInputLayout.java

示例10: TabSwitcherDrawable

import android.text.TextPaint; //导入方法依赖的package包/类
private TabSwitcherDrawable(Resources resources, boolean useLight, Bitmap bitmap) {
    super(resources, bitmap);
    setTint(ApiCompatibilityUtils.getColorStateList(resources,
            useLight ? R.color.light_mode_tint : R.color.dark_mode_tint));
    mSingleDigitTextSize =
            resources.getDimension(R.dimen.toolbar_tab_count_text_size_1_digit);
    mDoubleDigitTextSize =
            resources.getDimension(R.dimen.toolbar_tab_count_text_size_2_digit);

    mTextPaint = new TextPaint();
    mTextPaint.setAntiAlias(true);
    mTextPaint.setTextAlign(Align.CENTER);
    mTextPaint.setTypeface(Typeface.create("sans-serif-condensed", Typeface.BOLD));
    mTextPaint.setColor(getColorForState());
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:16,代码来源:TabSwitcherDrawable.java

示例11: init

import android.text.TextPaint; //导入方法依赖的package包/类
private void init(AttributeSet attrs, int defStyle) {
    final TypedArray a = getContext().obtainStyledAttributes(
            attrs, R.styleable.RoundedLetterView, defStyle, 0);

    if(a.hasValue(R.styleable.RoundedLetterView_rlv_titleText)){
        mTitleText = a.getString(R.styleable.RoundedLetterView_rlv_titleText);
    }

    mTitleColor = a.getColor(R.styleable.RoundedLetterView_rlv_titleColor,DEFAULT_TITLE_COLOR);
    mBackgroundColor = a.getColor(R.styleable.RoundedLetterView_rlv_backgroundColorValue,DEFAULT_BACKGROUND_COLOR);

    mTitleSize = a.getDimension(R.styleable.RoundedLetterView_rlv_titleSize,DEFAULT_TITLE_SIZE);
    a.recycle();

    //Title TextPaint
    mTitleTextPaint = new TextPaint();
    mTitleTextPaint.setFlags(Paint.ANTI_ALIAS_FLAG);
    mTitleTextPaint.setTypeface(mFont);
    mTitleTextPaint.setTextAlign(Paint.Align.CENTER);
    mTitleTextPaint.setLinearText(true);
    mTitleTextPaint.setColor(mTitleColor);
    mTitleTextPaint.setTextSize(mTitleSize);

    //Background Paint
    mBackgroundPaint = new Paint();
    mBackgroundPaint.setFlags(Paint.ANTI_ALIAS_FLAG);
    mBackgroundPaint.setStyle(Paint.Style.FILL);
    mBackgroundPaint.setColor(mBackgroundColor);

    mInnerRectF = new RectF();
}
 
开发者ID:broakenmedia,项目名称:MultiContactPicker,代码行数:32,代码来源:RoundLetterView.java

示例12: GifBadge

import android.text.TextPaint; //导入方法依赖的package包/类
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();
}
 
开发者ID:gejiaheng,项目名称:Protein,代码行数:30,代码来源:BadgedFourThreeImageView.java

示例13: updateDrawState

import android.text.TextPaint; //导入方法依赖的package包/类
@Override
public void updateDrawState(TextPaint ds) {
    super.updateDrawState(ds);
    ds.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
    ds.setUnderlineText(false);
}
 
开发者ID:pooyafaroka,项目名称:PlusGram,代码行数:7,代码来源:URLSpanNoUnderlineBold.java

示例14: updateDrawState

import android.text.TextPaint; //导入方法依赖的package包/类
@Override
public void updateDrawState(TextPaint ds) {
    super.updateDrawState(ds);
    ds.setTypeface(FontManager.instance().getTypeface());
    ds.setUnderlineText(false);
}
 
开发者ID:MLNO,项目名称:airgram,代码行数:7,代码来源:URLSpanNoUnderlineBold.java

示例15: buildSrcFromName

import android.text.TextPaint; //导入方法依赖的package包/类
@SuppressWarnings("ResourceAsColor")
private Bitmap buildSrcFromName(final String firstChar, int w, int h) {
    if (w == Target.SIZE_ORIGINAL || w <= 0)
        w = 80;
    if (h == Target.SIZE_ORIGINAL || h <= 0)
        h = 80;

    final int size = Math.max(Math.min(Math.min(w, h), 220), 64);
    final float fontSize = size * 0.4f;
    log("firstChar:" + firstChar + " size:" + size + " fontSize:" + fontSize);

    Bitmap bitmap = Bitmap.createBitmap(size, size, Bitmap.Config.RGB_565);

    TextPaint paint = new TextPaint(Paint.ANTI_ALIAS_FLAG);
    paint.setAntiAlias(true);
    paint.setDither(true);
    paint.setColor(Color.WHITE);
    paint.setTextAlign(Paint.Align.CENTER);
    paint.setTextSize(fontSize);
    paint.setTypeface(Typeface.SANS_SERIF);

    // check ASCII
    final int charNum = Character.getNumericValue(firstChar.charAt(0));
    if (charNum > 0 && charNum < 177) {
        Typeface typeface = getFont(getContext(), "Numans-Regular.otf");
        if (typeface != null)
            paint.setTypeface(typeface);
    }

    Rect rect = new Rect();
    paint.getTextBounds(firstChar, 0, 1, rect);
    int fontHeight = rect.height();
    log(rect.toString());

    int fontHalfH = fontHeight >> 1;
    int centerX = bitmap.getWidth() >> 1;
    int centerY = bitmap.getHeight() >> 1;

    Canvas canvas = new Canvas(bitmap);
    canvas.drawColor(getBackgroundColor(firstChar));
    canvas.drawText(firstChar, centerX, centerY + fontHalfH, paint);

    return bitmap;
}
 
开发者ID:hsj-xiaokang,项目名称:OSchina_resources_android,代码行数:45,代码来源:PortraitView.java


注:本文中的android.text.TextPaint.setTypeface方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。