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 8299847
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T16:18:57+00:00 2026-06-08T16:18:57+00:00

Using Android canvas draw commands: If I set stroke = 0 or stroke =1

  • 0

Using Android canvas draw commands:

If I set stroke = 0 or stroke =1 and draw horizontal line, the line pixels are two pixels high. If I set stroke = 2, the pixels are also two pixels high but are brighter.

If I draw single pixels, the pixels are a 2×2 matrix for stroke = 0 or stroke = 1. If the stroke = 2, I also get a 2×2 matrix but with brighter pixels.

What must I do to get lines that are only one pixel tall?
What must I do to get pixels that are one and only pixel?

Note: The devices that am using have screen sizes of 480 x 800 or greater.

Paint thePaint = new Paint();                   
thePaint.setARGB(a, r, g, b);                           
thePaint.setAntiAlias(true);
thePaint.setStyle(Paint.Style.FILL );
thePaint.setStrokeWidth(0);
canvas.drawLine(x1,y1,x2,y2, thePaint);
  • 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-08T16:19:00+00:00Added an answer on June 8, 2026 at 4:19 pm

    I communicated with The Roman Guy @Google about this issue. He said the AntiAlias need to be turned off in addition of setting stroke = 0. My testing showed that he is right. The Google documentation does not current reflect this requirement. This code works.

    Paint thePaint = new Paint();                   
    thePaint.setARGB(a, r, g, b);                           
    thePaint.setAntiAlias(false);
    thePaint.setStyle(Paint.Style.STROKE );
    thePaint.setStrokeWidth(0);
    canvas.drawLine(x1,y1,x2,y2, thePaint);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can I draw a line using canvas to connect two buttons in android
I am using Canvas.drawCircle to draw a circle in Android laout. Method gets 3
Why draw operation in android canvas are using float instead of int for (x,y)?
I've set of n points and I want to draw a n-sided polygon using
I'm trying to draw a line on canvas and project it into a map
I have used to draw pie chart using canvas.. There are approximately 10 arcs
I'm trying to draw text without antialiasing on a canvas in Android. The font
I want to draw five rectangle bars in Android. I have the regtangles, but
I'm making my first game using Java on Android. I need to draw a
I'm trying to draw a nine patch onto a Canvas object on the Android.

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.