Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9200243
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T22:43:19+00:00 2026-06-17T22:43:19+00:00

I want to draw on canvas month’s text vertical along screen height. Paint init:

  • 0

I want to draw on canvas month’s text vertical along screen height.

Paint init:

   this.paint = new Paint();
   this.paint.setAntiAlias(true);
   this.paint.setDither(true);
   this.paint.setSubpixelText(true);
   this.paint.setColor(color_text_dark);
   this.paint.setTextAlign(Align.RIGHT);

Drawing:

   // Set the scale to the widest month
   float scale = getHeight() / this.max_month_width;
   String month_string = FULL_MONTH_NAME_FORMATTER.
                         format(active_month_calendar.getTime());
   canvas.save();
   canvas.translate(getWidth(), 0);
   canvas.rotate(-90);
   canvas.scale(scale, scale);
   canvas.drawText(month_string, 0, 0, this.paint);
   canvas.restore();

Result looks good on hdpi screen, but very ugly and pixelated on xhdpi one.

I did more test on various devices, and understood what result depends on Android version, not screen density and resolution.

Code works fine on 2.x platform, but doesn’t work on 4.0.3+. Suppose, Android draw implementation was changed here.
Full code you can see here.

hdpi version 2.3.5 (also tested 2.2)

hdpi

xhdpi version 4.2 (also tested 4.1, 4.0.3)

xhdpi

Trying different variations for paint antialias, subpixel text has no effect. How can I fix this issue?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T22:43:21+00:00Added an answer on June 17, 2026 at 10:43 pm

    The problem is that you’re drawing text at one size and scaling the result up. Once you’ve determined how wide you want the text to be, you should use calls to Paint.measureText(), adjusting the size via Paint.setTextSize() accordingly. Once it measures correctly, then you do your call to Canvas.drawText().

    An alternative would be to not measure the text at all and just immediately call:

    paint.setTextSize(paint.getSize() * scale)
    

    There’s no guarantee the text will fit in this case, though.

    None of your other transform calls should result in interpolation, so it should give you very sharp lines.

    Edit

    Here is a code sample and comparison screenshot:

    canvas.save();
    canvas.scale(10, 10);
    canvas.drawText("Hello", 0, 10, mTextPaint);
    canvas.restore();
    float textSize = mTextPaint.getTextSize();
    mTextPaint.setTextSize(textSize * 10);
    canvas.drawText("Hello", 0, 300, mTextPaint);
    mTextPaint.setTextSize(textSize);
    

    Your rendering method on top, mine on bottom

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to draw text on canvas., how to do it any sample example?
I want to draw a widget (in this example, a canvas) and then remove
So I want to be able to draw onto this canvas I created, let
I am working with canvas in android. i want to draw shapes on canvas
I want to draw an arc using canvas using a gradient fill. How can
I want to draw a picture (bmp,jpg,png) into the canvas (using the onDraw() method)
hi i want to draw path into canvas but it does not do anything,
I have a Bitmap object that I want to draw on canvas with some
I derived the Canvas class where in the paint method I draw an Image
I am using below code to set text on the canvas..But now i want

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.