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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T01:27:26+00:00 2026-05-17T01:27:26+00:00

How can i draw a view on a canvas by giving the x,y position

  • 0

How can i draw a view on a canvas by giving the x,y position in the canvas.

For example,
I have custom view myView, which was created by inflating one of my layout.xml file.
Now i want to draw this myView on the canvas at position (x, y).

How can i do that?

Please help with your ideas.

Thanks,
Sen

Updated:

To be more specific,
I have

myView extend view { 
... 
protected void onDraw(Canvas canvas) {  
super.onDraw(canvas);  
    { Inside which i will draw a curve }  

Then I will obtain 8 set of co-ordinates along the path and will store it in a list.

Then i have created a new view by using Absolute layout and its name is myinfo.xml(which contains two text views) present inside the res/layouts folder.

Now i want to inflate this view inside the onDraw method and want to place them in the above collected co-ordinates.

But i tried to inflate the view in this class(myView) but it is not working.

Please tell where am i wrong??

If you have some other suggestion, do update me.

Thanks & Regards,
Sen

  • 1 1 Answer
  • 1 View
  • 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-05-17T01:27:27+00:00Added an answer on May 17, 2026 at 1:27 am

    Call save() on your Canvas to save the properties. Then you can do any operations you like, e.g. call clipRect(float left, float top, float right, float bottom) to clip the region of your view and then draw it on the canvas.

    After you are done, call restoreToCount(int saveCount) using the integer returned by the save() command before to restore the Canvas’ properties. 🙂

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

Sidebar

Related Questions

I have a view inflated, I can draw it on canvas, but can't seem
I have a custom view which I override the onDraw method to draw bitmaps
I have a custom SurfaceView defined in my layout xml. I can draw to
How I can draw bezier curve in canvas. I have only start point and
I want to have a View where i can draw when the user touches
i have a Custom view ... package nan.salsa.goal.customview; import android.R; import android.content.Context; import android.graphics.Canvas;
I have a drawing activity that creates a custom 'canvas' View that occupies the
I'm trying to draw to a Bitmap so I can put my custom view
I need to draw text to a canvas (of a custom view), and need
I need to draw text in the middle of a view, the text can

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.