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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T22:03:39+00:00 2026-05-20T22:03:39+00:00

I’m not sure I’m doing this the right way, so I’m open to other

  • 0

I’m not sure I’m doing this the “right” way, so I’m open to other options as well. Here’s what I’m trying to accomplish:

I want a view which contains a graph. The graph should be dynamically created by the app itself. The graph should be zoom-able, and will probably start out larger than the screen (800×600 or so)

I’m planning on starting out simple, just a scatter plot. Eventually, I want a scatter plot with a fit line and error bars with axis that stay on the screen while the graph is zoomed … so that probably means three images overlaid with zoom functions tied together.

I’ve already built a view that can take a drawable, can use focused pinch-zoom and drag, can auto-scale images, can switch images dynamically, and takes images larger than the screen. Tying the images together shouldn’t be an issue.

I can’t, however, figure out how to dynamically draw simple images.

For instance: Do I get a BitMap object and draw on it pixel by pixel? I wanted to work with some of the ShapeDrawables, but it seems they can only draw a shape onto a canvas … how then do I get a bitmap of all those shapes into my view? Or alternately, do I have to dynamically redraw /all/ of the image I want to portray in the “onDraw” routine of my view every time it moves or zooms?

I think the “perfect” solution would be to use the ShapeDrawable (or something like it to draw lines and label them) to draw the axis with the onDraw method of the view … keep them current and at the right level … then overlay a pre-produced image of the data points / fit curve / etc that can be zoomed and moved. That should be possible with white set to an alpha on the graph image.

PS: The graph image shouldn’t actually /change/ while on the view. It’s just zooming and being dragged. The axis will probably actually change with movement. So pre-producing the graph before (or immediately upon) entering the view would be optimal. But I’ve also noticed that scaling works really well with vector images … which also sounds appropriate (rather than a bitmap?).

So I’m looking for some general guidance. Tried reading up on the BitMap, ShapeDrawable, Drawable, etc classes and just can’t seem to find the right fit. That makes me think I’m barking up the wrong tree and someone with some more experience can point me in the right direction. Hopefully I didn’t waste my time building the zoom-able view I put together yesterday :).

  • 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-05-20T22:03:40+00:00Added an answer on May 20, 2026 at 10:03 pm

    First off, it is never a waste of time writing code if you learned something from it. 🙂

    There is unfortunately still no support for drawing vector images in Android. So bitmap is what you get.

    I think the bit you are missing is that you can create a Canvas any time you want to draw on a bitmap. You don’t have to wait for onDraw to give you one.

    So at some point (from onCreate, when data changes etc), create your own Bitmap of whatever size you want.

    Here is some psuedo code (not tested)

    Bitmap mGraph;
    
    void init() {
        // look at Bitmap.Config to determine config type
        mGraph = new Bitmap(width, height, config);
        Canvas c = new Canvas(mybits);
        // use Canvas draw routines to draw your graph
    }
    
    // Then in onDraw you can draw to the on screen Canvas from your bitmap.
    protected void onDraw(Canvas canvas) {
        Rect dstRect = new Rect(0,0,viewWidth, viewHeight);
        Rect sourceRect = new Rect();
        // do something creative here to pick the source rect from your graph bitmap
        // based on zoom and pan 
        sourceRect.set(10,10,100,100);
    
        // draw to the screen
        canvas.drawBitmap(mGraph, sourceRect, dstRect, graphPaint);
    }
    

    Hope that helps a bit.

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

Sidebar

Related Questions

I'm not entirely sure how I managed to jack this up. http://pretty-senshi.com If you
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I know there's a lot of other questions out there that deal with this
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
For some reason, after submitting a string like this Jack’s Spindle from a text
I want to count how many characters a certain string has in PHP, but
Basically, what I'm trying to create is a page of div tags, each has

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.