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

  • Home
  • SEARCH
  • 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 9038737
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T09:33:36+00:00 2026-06-16T09:33:36+00:00

Okay, this is driving me nuts. I am using canvas to draw a gauge

  • 0

Okay, this is driving me nuts. I am using canvas to draw a gauge in my app. It also draws numbers on the hash marks and some horizontal text across the gauge. This all works fine in all versions of Android up to 4.2. In 4.2, it is only drawing one character (the middle character it seems) from the text it’s supposed to write. For example, if I have text that reads 12345, it’s only writing 3. If it’s a two digit number, it only draws the first digit. I ‘m seeing this behavior in the 4.2 emulator and on a Nexus 4 with 4.2.1. I read all about the hardware acceleration being turned on by default and that it causes problems with some Paint and Canvas features. I have inserted the code to turn off hardware acceleration for the drawText calls, but it doesn’t help.

Here is my paint code:

titlePaint1 = new Paint();
titlePaint1.setColor(Color.WHITE);
titlePaint1.setAntiAlias(true);
titlePaint1.setTypeface(Typeface.DEFAULT_BOLD);
titlePaint1.setTextAlign(Paint.Align.CENTER);
titlePaint1.setTextSize(0.085f);

Here is the method called to draw the text:

@SuppressLint("NewApi")
private void drawTitle1(Canvas canvas) {
    if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB)
        setLayerType(View.LAYER_TYPE_SOFTWARE, titlePaint1);

    canvas.drawText(title1, 0.5f, 0.72f, titlePaint1);
}

I pass it the canvas which is valid and the width and height are perfect. Everything else getting drawn on that canvas is displaying fine and there are three other calls to functions, like the one above, before it that draw the components of the gauge. It’s just an issue with drawText. I know it has something to do with a change in 4.2 and I don’t think this drawText issue has anything to do with hardware acceleration. I’ve only been able to find a few results on Google talking about Canvas issues with 4.2, but nothing has helped me to resolve my issue. Any ideas how I can resolve this and get the text to display properly?

  • 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-16T09:33:37+00:00Added an answer on June 16, 2026 at 9:33 am

    Thank you to “Seraphim’s host” for the answer to this in their post. For any others having this issue with 4.2.1, the answer is to include setLinearText(true) on your paint for the text. This method is showing as deprecated, but it’s the only solution for the text to display properly.

    Here is the post with the answer: https://stackoverflow.com/a/13971632/1017328.

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

Sidebar

Related Questions

Okay so this was driving me nuts all day. Why does this happen: class
Okay, this is driving me nuts. I’m working through the IBM CakePHP Tutorial, and
Okay, this is driving me nuts...I have this site where there is horizontal scrolling
Okay this is the first place in my app I'm using a block for
Okay, this sounds stupid but this is driving me nuts. I have been working
Okay this is my first WPF app and I am having a hard run
Okay, this is driving me crazy right now. I want to have a border
Okay this could very likely be a silly question. I am using Entity Framework
Okay this is a fairly broad question. This is my first App and I'm
This is driving me nuts. FactoryGirl has stopped working, but I can't see why

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.