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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T10:51:43+00:00 2026-06-07T10:51:43+00:00

I am looking for a real example with sample code on how to draw

  • 0

I am looking for a real example with sample code on how to draw on canvas greater than screen size ( As of now I am drawing normally and not able to view outside screen size). More stress is on being able to scroll / pan the screen to view the whole canvas.
If anymore info is required please comment.

Update: Found my answer here Image in Canvas with touch events

  • 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-07T10:51:45+00:00Added an answer on June 7, 2026 at 10:51 am

    My version is converted from Monodroid, but the implementation should look about the same. (I tried putting it back into java, apologies if it is not exact)

    1. In order to draw outside the screen, just draw where ever you want, it will be drawn outside the screen. The trick is to see it by zooming and panning. For zooming your view needs to implement ScaleGestureDetector.IOnScaleGestureListener and implement the onScale method as below.

    2. For panning you just need to implement the onTouchEvent, which is required for zooming anyway.

      private float _scaleFactor;
      private float _xoffset;
      private float _yoffset;
      
      @override
      public bool onScale(ScaleGestureDetector detector){
          _scaleFactor *= detector.ScaleFactor;
          _scaleFactor = Math.Max(0.1f, Math.Min(_scaleFactor, 5.0f));
          invalidate();
          return true;
      } 
      
      @override 
      protected void onDraw(Canvas canvas){
          super.onDraw(canvas);
          canvas.save();
          canvas.scale(_scaleFactor, _scaleFactor);//for zoom
          canvas.translate(_xoffset, _yoffset);//for pan
          //DO NORMAL DRAWING HERE
          canvas.restore();
      }
      
      @override 
      public bool onTouchEvent(MotionEvent e){
          switch (e.action){
              case MotionEvent.ACTION_DOWN:{                        
                  _prevx = e.getX();
                  _prevy = e.getY();
              }
              break;
              case MotionEvent.ACTION_UP:{
                  _xoffset += e.getX() - _prevx;
                  _yoffset += e.getY() - _prevy;
                  invalidate();
      
                  _prevx = e.getX();
                  _prevy = e.getY();
              }
              break;
          }
          return _scaleGestureDetector.onTouchEvent(e);
      }
      

    NOTE: This code is for a custom VIEW object – so inherit from View and implement IOnScaleGestureListener

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

Sidebar

Related Questions

I'm looking for help on now to use TDD for a real world example.
Do you know of any way to do it? real example...? I am looking
I am looking to use my screen real estate to look at several simple
I'm looking for some examples or sample code for properly organizing my code for
This may be silly, but I'm looking for so-called 'real life' examples of software
i'm looking to parse the real time rates from this webpage: http://www.truefx.com/ into my
I was looking through the docs and stumbled onto mysql_real_escape_string() and I'm not understanding
I am looking for a wiki engine that is: open source real time collaborative
I am implementing a system where I need real-time updates. I have been looking
Looking at some assembly code for x86_64 on my Mac, I see the following

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.