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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T09:15:18+00:00 2026-06-01T09:15:18+00:00

I have this code. Only the first drawLine gets drawn and the rest 2

  • 0

I have this code.
Only the first drawLine gets drawn and the rest 2 are not. Can anyone explain why the other two drawlines do not work in the present case?
They work if I replace “factor” with “1/2” in the drawLine() statements.
Thanks

public class RenderView extends View {

Paint paint;
private float factor = 1/2;

public RenderView(Context context) {
    // TODO Auto-generated constructor stub
    super(context);
    paint = new Paint(Paint.ANTI_ALIAS_FLAG);
}

@Override
protected void onDraw(Canvas canvas) {

    int screenWidth = canvas.getWidth();
    int screenHeight = canvas.getHeight();

    paint.setColor(Color.RED);


    canvas.drawLine(0, 0, screenWidth, screenHeight, paint);

    canvas.drawLine(factor*screenWidth, 0, factor*screenWidth, screenHeight, paint);


    canvas.drawLine(0, factor*screenHeight, screenWidth, factor*screenHeight, paint);

    invalidate();       
}

}

  • 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-01T09:15:19+00:00Added an answer on June 1, 2026 at 9:15 am

    1/2 is 0 (by integer division). Try 1f/2 or just 0.5f.

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

Sidebar

Related Questions

I have this Perl code that is only printing the first line instead of
I have this code and its only returning the first string [0] and errors
I have this piece of code, and I need to target only the first
I have this code to run a slideshow (this is only part of what
I have this code in C (it's for study only): char x; uint64_t total
I have this code so I can grab the values ind the dataset before
I have this code in my cfm, which works <cfif not StructIsEmpty(form)> <cfset larray
First of all, I think this question is not C# independent. But can also
I have this code that extracts the first image from an article in joomla:
i have this code, but i can't understand why var_dump($jobs[0][0]) return Some Director ,

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.