當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。