Paint setTextSize - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Paint setTextSize method.

This code example shows how to use the following methods:measureText, setTextSize, setTypeface
     * @param view 
     * @param numberOfDigits 
     * @return number width 
     */ 
    public static int getWidth(TextView view, int numberOfDigits) {
        Paint paint = new Paint();
        paint.setTypeface(view.getTypeface());
        paint.setTextSize(view.getTextSize());
        char[] text = new char[numberOfDigits];
        Arrays.fill(text, '0');
        return Math.round(paint.measureText(text, 0, text.length));
    } 
 
    /** 
     * Get octicons typeface 
     * 
     * @param context 
     * @return octicons typeface 
     */ 
    public static Typeface getOcticons(final Context context) {
9
CodeRank
This code example shows how to use the following methods:setAntiAlias, setColor, setTextSize
        private final Paint mHugePaint;
 
        CustomTextView(Context c) {
            super(c);
 
            mHugePaint = new Paint();
            mHugePaint.setAntiAlias(true);
            mHugePaint.setColor(0xff000000);
            mHugePaint.setTextSize(300f);
        } 
 
        @Override 
        protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
            setMeasuredDimension(MeasureSpec.getSize(widthMeasureSpec), 3000);
        } 
 
        @Override 
        protected void onDraw(Canvas canvas) {
            super.onDraw(canvas);
            canvas.drawRGB(255, 255, 255);
9
CodeRank
This code example shows how to use the following methods:setAntiAlias, setFakeBoldText, setTextSize
            mHugePaint = new Paint();
            mHugePaint.setAntiAlias(true);
            mHugePaint.setColor(0xff000000);
            mHugePaint.setTextSize(300f);
 
            mEventPaint = new TextPaint();
            mEventPaint.setFakeBoldText(true);
            mEventPaint.setAntiAlias(true);
            mEventPaint.setTextSize(14);
        } 
 
        @Override 
        protected void onDraw(Canvas canvas) {
            super.onDraw(canvas);
            canvas.drawRGB(255, 255, 255);
 
            canvas.drawText("Hello OpenGL renderer!", 300, 20, mEventPaint);
             
            mMediumPaint.setStyle(Paint.Style.FILL_AND_STROKE);
            mMediumPaint.setStrokeWidth(2.0f);
8
CodeRank
This code example shows how to use the following methods:getFontMetricsInt, measureText, setColor, setTextAlign, setTextSize
This code example shows how to use the following methods:setAntiAlias, setColor, setFakeBoldText, setTextSize
This code example shows how to use the following methods:setColor, setStyle, setTextAlign, setTextSize
 
    // --- painting code 
 
    @Override 
    protected void onDraw(Canvas canvas) {
        Paint paint = new Paint();
        paint.setColor(BG_COLOR);
        paint.setStyle(Paint.Style.FILL);
        canvas.drawRect(0, 0, getWidth(), getHeight(), paint);
 
        paint.setColor(FILTER_COLOR);
        Path path = new Path();
        path.moveTo(getWidth() * (0.5f - 0.5f * start / max), 0);
        path.lineTo(getWidth() * (0.5f + 0.5f * start / max), 0);
        path.lineTo(getWidth() * (0.5f + 0.5f * end / max), getHeight());
        path.lineTo(getWidth() * (0.5f - 0.5f * end / max), getHeight());
        path.close();
        canvas.drawPath(path, paint);
 
        paint.setColor(TEXT_COLOR);

9
CodeRank
This code example shows how to use the following methods:setAntiAlias, setColor, setStyle, setTextAlign, setTextSize
        baseApi.end();
    } 
 
    private static Bitmap getTextImage(String text, int width, int height) {
        final Bitmap bmp = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
        final Paint paint = new Paint();
        final Canvas canvas = new Canvas(bmp);
 
        canvas.drawColor(Color.WHITE);
 
        paint.setColor(Color.BLACK);
        paint.setStyle(Style.FILL);
        paint.setAntiAlias(true);
        paint.setTextAlign(Align.CENTER);
        paint.setTextSize(24.0f);
        canvas.drawText(text, width / 2, height / 2, paint);
 
        return bmp;
    } 
 
8
CodeRank
This code example shows how to use the following methods:setColor, setTextSize
        mFramesCouner = 0;
        mFrequency = Core.getTickFrequency();
        mprevFrameTime = Core.getTickCount();
        mStrfps = "";
 
        mPaint = new Paint();
        mPaint.setColor(Color.BLUE);
        mPaint.setTextSize(20);
    } 
 
    public void measure() { 
        if (!mIsInitialized) {
            init(); 
            mIsInitialized = true;
        } else { 
            mFramesCouner++;
            if (mFramesCouner % STEP == 0) {
                long time = Core.getTickCount();
                double fps = STEP * mFrequency / (time - mprevFrameTime);
                mprevFrameTime = time;
8
CodeRank
This code example shows how to use the following methods:setAlpha, setColor, setColorFilter, setTextSize
     * @see android.graphics.drawable.Drawable#draw( 
     *    android.graphics.Canvas) 
     */ 
    @Override 
    public void draw(Canvas canvas) {
        Paint paint = new Paint();
 
        paint.setColorFilter(filter);
        paint.setAlpha(opacity);
 
        paint.setTextSize(12);
        paint.setColor(Color.GREEN);
        canvas.drawText("Hello", 40, 55, paint);
 
        paint.setTextSize(16);
        paint.setColor(Color.RED);
        canvas.drawText("Android", 35, 65, paint);
    } 
 
    /** @see android.graphics.drawable.Drawable#getOpacity() */ 
    @Override 
8
CodeRank
This code example shows how to use the following methods:setAntiAlias, setColor, setStrokeWidth, setStyle, setTextSize

Related Paint setTextSize Questions & Answers:

setTextSize Method Overview
Set the paint's text size.
See Code Examples for other Android Paint Methods: