Issue: Image is zoomed on the android canvas.

This is a discussion on Issue: Image is zoomed on the android canvas. within the Beginning Developers forums, part of the Android Development category; Hello, I am drawing an image Code: canvas.drawBitmap(bg,0,0,null); of size 480 x 320, but I am not getting the correct size image on the screen. ...

Results 1 to 2 of 2

Thread: Issue: Image is zoomed on the android canvas.

  1. #1
    Android Lurker Rahul Thakur's Avatar
    Join Date
    Jun 2011
    Posts
    2

    Issue: Image is zoomed on the android canvas.

    Hello,

    I am drawing an image
    Code:
    canvas.drawBitmap(bg,0,0,null);
    of size 480 x 320, but I am not getting the correct size image on the screen. It's showing a zoomed out image & only part of the Image is visible.

    I have remove the title and status bar from the window.

    Code:
    requestWindowFeature(Window.FEATURE_NO_TITLE);
        getWindow().setFlags(
            WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN
        );
    I have set the view as

    Code:
    setContentView( new gamePanel(this));
        class gamePanel extends View
        {
        ...
          public void onDraw(Canvas canvas)
          {
            // -> Here I am calling the draw function.
          }
        ...
        }
    I am getting the canvas height and width as 231x320(but I should get 320x480),
    which less than the android emulator size 320X480.

    I am not understanding, how can I solve this issue so that, I can get proper size image on the screen.

  2. Android.net is the premier Android Forum. Registered users do not see these ads. .

  3. #2
    App Developer alostpacket's Avatar
    Join Date
    Jan 2011
    Location
    NY
    Posts
    240
    Thanked
    32 times
    Twitter
    alostpacket
    It's hard to say with the code you posted, I dont have much experience with using the cavas either.

    But if I had to guess, from the looks of it you are getting the width and heigh before the API framework has removed the title bar and/or notifications bar.

    My guess would also be you are somehow getting half the height. You may want to try something like using an initial layout.xml that ensures you set the content view to fullscreen and no titlebar.

    Another thing to try would be to not draw on the canvas until AFTER the content view has been set. Say setting your content view to a linear layout with canvas as a child.

    These are kinda just guesses though so I'm not sure if they will help or not.

Remove Ads

http://www.scramblerducati.org/

Sponsored Links

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Similar Threads

  1. Android Canvas Example
    By jsliu111 in forum Beginning Developers
    Replies: 0
    Last Post: 04-30-2011, 02:14 PM
  2. G2/Android Contact Import Issue
    By G2 Forum User in forum HTC G2
    Replies: 8
    Last Post: 04-28-2011, 11:35 AM
  3. How to Draw TextView on Canvas in android..?
    By Rajesh Kalhotra in forum Beginning Developers
    Replies: 3
    Last Post: 03-09-2011, 03:41 PM
  4. How to Draw TextView on Canvas in android..?
    By Rajesh Kalhotra in forum Android Forum
    Replies: 2
    Last Post: 03-09-2011, 03:55 AM

Search tags for this page

android canvas size

,

android canvas zoom

,

android canvas zoom example

,

android code canvas image

,
android development canvas image full size
,
android how to zoom in/out image on canvas
,

android screen zoom on part

,

android smaller image size when zoomed

,
android zooming textview example
,

canvas zoom android

,

canvas.drawbitmap fit to screen

,
get canvas size android
,

image zoom code in android

,

zoom canvas android

,
zoom canvas in android
Click on a term to search our sites for related topics.
Android Forum