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


Java TextPaint.setTextSize方法代码示例

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


在下文中一共展示了TextPaint.setTextSize方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: initPaint

import android.text.TextPaint; //导入方法依赖的package包/类
/**
 * define paints
 */
private void initPaint() {
    // round rectangle paint
    mStrokePaint = new Paint();
    mStrokePaint.setColor(mSelectedColor);
    mStrokePaint.setStyle(Paint.Style.STROKE);
    mStrokePaint.setAntiAlias(true);
    mStrokePaint.setStrokeWidth(mStrokeWidth);
    // selected paint
    mFillPaint = new Paint();
    mFillPaint.setColor(mSelectedColor);
    mFillPaint.setStyle(Paint.Style.FILL_AND_STROKE);
    mStrokePaint.setAntiAlias(true);
    // selected text paint
    mSelectedTextPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG);
    mSelectedTextPaint.setTextSize(mTextSize);
    mSelectedTextPaint.setColor(mSelectedColor);
    mStrokePaint.setAntiAlias(true);
    // unselected text paint
    mUnselectedTextPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG);
    mUnselectedTextPaint.setTextSize(mTextSize);
    mUnselectedTextPaint.setColor(0xffffffff);
    mStrokePaint.setAntiAlias(true);
    mTextHeightOffset = -(mSelectedTextPaint.ascent() + mSelectedTextPaint.descent()) * 0.5f;
}
 
开发者ID:DSM-DMS,项目名称:DMS,代码行数:28,代码来源:SwitchMultiButton.java

示例2: 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();
    }
}
 
开发者ID:Fueled,项目名称:snippety,代码行数:25,代码来源:TextIndentSpan.java

示例3: init

import android.text.TextPaint; //导入方法依赖的package包/类
private void init() {
    bgPaint = new Paint();
    bgPaint.setAntiAlias(true);
    bgPaint.setStyle(Paint.Style.FILL);
    bgPaint.setColor(bgColor);
    bgPaint.setStrokeWidth(lineBgWidth);

    proPaint = new Paint();
    proPaint.setAntiAlias(true);
    proPaint.setStyle(Paint.Style.FILL);
    proPaint.setColor(proColor);
    proPaint.setStrokeWidth(lineProWidth);

    textPaint = new TextPaint();
    textPaint.setTextSize(textsize);
    textPaint.setAntiAlias(true);
}
 
开发者ID:JJS-CN,项目名称:JBase,代码行数:18,代码来源:FlowViewVertical.java

示例4: getSingleLineTextSize

import android.text.TextPaint; //导入方法依赖的package包/类
/**
 * Recursive binary search to find the best size for the text.
 * <p>
 * Adapted from https://github.com/grantland/android-autofittextview
 */
public static float getSingleLineTextSize(String text,
                                          TextPaint paint,
                                          float targetWidth,
                                          float low,
                                          float high,
                                          float precision,
                                          DisplayMetrics metrics) {
    final float mid = (low + high) / 2.0f;

    paint.setTextSize(TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_PX, mid, metrics));
    final float maxLineWidth = paint.measureText(text);

    if ((high - low) < precision) {
        return low;
    } else if (maxLineWidth > targetWidth) {
        return getSingleLineTextSize(text, paint, targetWidth, low, mid, precision, metrics);
    } else if (maxLineWidth < targetWidth) {
        return getSingleLineTextSize(text, paint, targetWidth, mid, high, precision, metrics);
    } else {
        return mid;
    }
}
 
开发者ID:haihaio,项目名称:AmenEye,代码行数:28,代码来源:ViewUtil.java

示例5: TimerDrawable

import android.text.TextPaint; //导入方法依赖的package包/类
public TimerDrawable(Context context) {
    if (emptyTimerDrawable == null) {
        emptyTimerDrawable = context.getResources().getDrawable(R.drawable.header_timer);
        timerDrawable = context.getResources().getDrawable(R.drawable.header_timer2);
        timePaint = new TextPaint(Paint.ANTI_ALIAS_FLAG);
        timePaint.setTextSize(AndroidUtilities.dp(11));
        timePaint.setColor(0xffffffff);
        timePaint.setTypeface(FontManager.instance().getTypeface());
    }
}
 
开发者ID:MLNO,项目名称:airgram,代码行数:11,代码来源:TimerDrawable.java

示例6: 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

示例7: BotHelpCell

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

    textPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG);
    textPaint.setTextSize(AndroidUtilities.dp(16));
    textPaint.setColor(0xff000000);
    textPaint.linkColor = Theme.MSG_LINK_TEXT_COLOR;

    urlPaint = new Paint();
    urlPaint.setColor(Theme.MSG_LINK_SELECT_BACKGROUND_COLOR);
}
 
开发者ID:MLNO,项目名称:airgram,代码行数:12,代码来源:BotHelpCell.java

示例8: PopupAudioView

import android.text.TextPaint; //导入方法依赖的package包/类
public PopupAudioView(Context context) {
    super(context);
    if (backgroundMediaDrawableIn == null) {
        backgroundMediaDrawableIn = getResources().getDrawable(R.drawable.msg_in_photo);
        statesDrawable[0][0] = getResources().getDrawable(R.drawable.play_g);
        statesDrawable[0][1] = getResources().getDrawable(R.drawable.play_g_s);
        statesDrawable[1][0] = getResources().getDrawable(R.drawable.pause_g);
        statesDrawable[1][1] = getResources().getDrawable(R.drawable.pause_g_s);
        statesDrawable[2][0] = getResources().getDrawable(R.drawable.file_g_load);
        statesDrawable[2][1] = getResources().getDrawable(R.drawable.file_g_load_s);
        statesDrawable[3][0] = getResources().getDrawable(R.drawable.file_g_cancel);
        statesDrawable[3][1] = getResources().getDrawable(R.drawable.file_g_cancel_s);

        statesDrawable[4][0] = getResources().getDrawable(R.drawable.play_b);
        statesDrawable[4][1] = getResources().getDrawable(R.drawable.play_b_s);
        statesDrawable[5][0] = getResources().getDrawable(R.drawable.pause_b);
        statesDrawable[5][1] = getResources().getDrawable(R.drawable.pause_b_s);
        statesDrawable[6][0] = getResources().getDrawable(R.drawable.file_b_load);
        statesDrawable[6][1] = getResources().getDrawable(R.drawable.file_b_load_s);
        statesDrawable[7][0] = getResources().getDrawable(R.drawable.file_b_cancel);
        statesDrawable[7][1] = getResources().getDrawable(R.drawable.file_b_cancel_s);

        timePaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG);
        timePaint.setTextSize(AndroidUtilities.dp(16));
    }

    TAG = MediaController.getInstance().generateObserverTag();

    seekBar = new SeekBar(getContext());
    seekBar.setDelegate(this);
    progressView = new ProgressView();
}
 
开发者ID:MLNO,项目名称:airgram,代码行数:33,代码来源:PopupAudioView.java

示例9: updateMeasureState

import android.text.TextPaint; //导入方法依赖的package包/类
@Override
public void updateMeasureState(TextPaint ds) {
  if (mFontSize != -1) {
    ds.setTextSize(mFontSize);
  }

  updateTypeface(ds);
}
 
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:9,代码来源:FontStylingSpan.java

示例10: init

import android.text.TextPaint; //导入方法依赖的package包/类
/**
 * Initialize the view
 */
private final void init() {		
	
	// Foreground text paint
	mTextPaint = new Paint();
	mTextPaint.setAntiAlias(true);
	mTextPaint.setTextSize(16);
	mTextPaint.setColor(0xFF000000);
	
	// The shadow
	mTextPaintShadow = new TextPaint();
	mTextPaintShadow.setAntiAlias(true);
	mTextPaintShadow.setTextSize(16);
	mTextPaintShadow.setColor(0x00000000);
	
	// Base padding
	//setPadding(3, 3, 3, 3);
	
	mMovement =  new Vector2D(0,0);
	
	mOldMovement = new Vector2D(0,0);				
	
	// Create our edge paint
	mCurlEdgePaint = new Paint();
	mCurlEdgePaint.setAntiAlias(true);
	mCurlEdgePaint.setStyle(Paint.Style.STROKE);
//	mCurlEdgePaint.setColor(this.edgeColor);
	
//	mCurlEdgePaint.setShadowLayer(10, -5, 5, 0x99000000);
	
	
	// Set the default props, those come from an XML :D
	mCurlSpeed = 30;		
	mInitialEdgeOffset = 20;
	
}
 
开发者ID:ceji-longquan,项目名称:ceji_android,代码行数:39,代码来源:PageCurlAnimator.java

示例11: init

import android.text.TextPaint; //导入方法依赖的package包/类
private void init(AttributeSet attrs) {
    TypedArray array = getContext().obtainStyledAttributes(attrs, R.styleable.DragBadgeView);
    mText = mDrawText = array.getString(R.styleable.DragBadgeView_text);
    float textSize = array.getDimension(R.styleable.DragBadgeView_textSize, sp2px(10));
    int bgColor = array.getColor(R.styleable.DragBadgeView_bgColor, Color.RED);
    int textColor = array.getColor(R.styleable.DragBadgeView_textColor, Color.WHITE);
    mMaxMoveRange = array.getDimension(R.styleable.DragBadgeView_maxMoveRange, dp2px(80));
    mDragEnable = array.getBoolean(R.styleable.DragBadgeView_dragEnable, true);
    mMaxShowValue = array.getInt(R.styleable.DragBadgeView_maxShowValue, 99);
    array.recycle();

    mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mPaint.setColor(bgColor);

    mTextPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG);
    mTextPaint.setAntiAlias(true);
    mTextPaint.setTextAlign(Paint.Align.CENTER);
    mTextPaint.setTextSize(textSize);
    mTextPaint.setColor(textColor);

    if (mText == null) {
        mText = mDrawText = "-1";
    }

    measureText();

    //绘制文字及背景需要的RectF
    mTextRectF = new RectF();
}
 
开发者ID:fendoudebb,项目名称:DragBadgeView,代码行数:30,代码来源:DragBadgeView.java

示例12: getLineCount

import android.text.TextPaint; //导入方法依赖的package包/类
private static int getLineCount(CharSequence text, TextPaint paint, float size, float width,
                                DisplayMetrics displayMetrics) {
    paint.setTextSize(TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_PX, size,
            displayMetrics));
    StaticLayout layout = new StaticLayout(text, paint, (int) width,
            Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, true);
    return layout.getLineCount();
}
 
开发者ID:victorminerva,项目名称:AutoResizeEditText,代码行数:9,代码来源:AutofitHelper.java

示例13: applySuperScriptStyle

import android.text.TextPaint; //导入方法依赖的package包/类
public void applySuperScriptStyle(@NonNull TextPaint paint) {
    final float ratio;
    if (Float.compare(scriptTextSizeRatio, .0F) == 0) {
        ratio = SCRIPT_DEF_TEXT_SIZE_RATIO;
    } else {
        ratio = scriptTextSizeRatio;
    }
    paint.setTextSize(paint.getTextSize() * ratio);
    paint.baselineShift += (int) (paint.ascent() / 2);
}
 
开发者ID:noties,项目名称:Markwon,代码行数:11,代码来源:SpannableTheme.java

示例14: textPaint

import android.text.TextPaint; //导入方法依赖的package包/类
private TextPaint textPaint() {
    final TextPaint paint = new TextPaint();
    paint.setColor(Color.BLACK);
    paint.setAntiAlias(true);
    paint.setTextSize(24);
    paint.setTextAlign(Paint.Align.CENTER);
    return paint;
}
 
开发者ID:lidong1665,项目名称:AndroidPDF,代码行数:9,代码来源:Page.java

示例15: initPainters

import android.text.TextPaint; //导入方法依赖的package包/类
protected void initPainters() {
    if (showText) {
        textPaint = new TextPaint();
        textPaint.setColor(textColor);
        textPaint.setTextSize(textSize);
        textPaint.setAntiAlias(true);

        innerBottomTextPaint = new TextPaint();
        innerBottomTextPaint.setColor(innerBottomTextColor);
        innerBottomTextPaint.setTextSize(innerBottomTextSize);
        innerBottomTextPaint.setAntiAlias(true);
    }

    finishedPaint = new Paint();
    finishedPaint.setColor(finishedStrokeColor);
    finishedPaint.setStyle(Paint.Style.STROKE);
    finishedPaint.setAntiAlias(true);
    finishedPaint.setStrokeWidth(finishedStrokeWidth);

    unfinishedPaint = new Paint();
    unfinishedPaint.setColor(unfinishedStrokeColor);
    unfinishedPaint.setStyle(Paint.Style.STROKE);
    unfinishedPaint.setAntiAlias(true);
    unfinishedPaint.setStrokeWidth(unfinishedStrokeWidth);

    innerCirclePaint = new Paint();
    innerCirclePaint.setColor(innerBackgroundColor);
    innerCirclePaint.setAntiAlias(true);
}
 
开发者ID:smartbeng,项目名称:PaoMovie,代码行数:30,代码来源:DonutProgress.java


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