SDK2.1, WVGA800 return wrong getWidth(), getHeight()

Common bugs/problems with the Android SDK the Emulator and the ADT-Plugin.

SDK2.1, WVGA800 return wrong getWidth(), getHeight()

Postby sblantipodi » Tue Apr 06, 2010 12:50 am

As title,
g.getWidth()/getHeight()
return this value on the emulator with an avd
320x569

Is there someone who can help me understanding why please?
sblantipodi
Senior Developer
Senior Developer
 
Posts: 122
Joined: Fri Mar 26, 2010 1:41 pm

Top

Postby pskink » Tue Apr 06, 2010 6:12 am

see docs about <supports-screens> in the manifest

http://developer.android.com/intl/fr/gu ... ement.html
pskink
pskink
Master Developer
Master Developer
 
Posts: 719
Joined: Mon Nov 24, 2008 3:49 pm

Postby sblantipodi » Tue Apr 06, 2010 11:32 am

pskink wrote:see docs about <supports-screens> in the manifest

http://developer.android.com/intl/fr/gu ... ement.html


This is what I call an useful answer.
Really, really thanks!
sblantipodi
Senior Developer
Senior Developer
 
Posts: 122
Joined: Fri Mar 26, 2010 1:41 pm

Postby sblantipodi » Wed Apr 07, 2010 9:52 am

Hi,
I have added this lines to my manifest
Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1.  
  2. <supports-screens
  3.  
  4.        android:largeScreens="true"
  5.  
  6.        android:normalScreens="true"
  7.  
  8.        android:smallScreens="true"
  9.  
  10.        android:anyDensity="true" />
Parsed in 0.001 seconds, using GeSHi 1.0.8.4


but there is no way to avoid that images are scaled on WVGA 240dpi...
I have put the images in the drawable-nodpi folder, in this way works well on Level higer than 4 but it doesn't
works on Level3 and this for me is not acceptable.

Is there a way to avoid image scaling also using Level3?
Thanks.
sblantipodi
Senior Developer
Senior Developer
 
Posts: 122
Joined: Fri Mar 26, 2010 1:41 pm

Postby pskink » Wed Apr 07, 2010 9:58 am

if you want to support level3 (v1.5) then you cannot use <supports-screens> tag in the manifest
pskink
pskink
Master Developer
Master Developer
 
Posts: 719
Joined: Mon Nov 24, 2008 3:49 pm

Postby sblantipodi » Wed Apr 07, 2010 10:08 am

pskink wrote:if you want to support level3 (v1.5) then you cannot use <supports-screens> tag in the manifest


Thanks for your reply.
You are right, I'm reading that this attribute is supported from level4...
Is there a workaround that avoid image scaling from Level3 to Level7?
sblantipodi
Senior Developer
Senior Developer
 
Posts: 122
Joined: Fri Mar 26, 2010 1:41 pm

Top

Postby pskink » Wed Apr 07, 2010 10:24 am

if you want to support level3+ your display will always have 320x480 regardless of device physical dimensions (compatibility mode) and everything will be scaled to that size
pskink
pskink
Master Developer
Master Developer
 
Posts: 719
Joined: Mon Nov 24, 2008 3:49 pm

Postby sblantipodi » Wed Apr 07, 2010 10:29 am

pskink wrote:if you want to support level3+ your display will always have 320x480 regardless of device physical dimensions (compatibility mode) and everything will be scaled to that size


I can't belive in this shame, I need to find a solution.
sblantipodi
Senior Developer
Senior Developer
 
Posts: 122
Joined: Fri Mar 26, 2010 1:41 pm

Postby sblantipodi » Wed Apr 07, 2010 2:08 pm

Ok, suppose that I don't want to support Android 1.5 and I don't want to put my images in
drawable-nodpi

is it possible to draw a not resized image on a canvas on a WVGA resolution using level4?
if yes, how?
sblantipodi
Senior Developer
Senior Developer
 
Posts: 122
Joined: Fri Mar 26, 2010 1:41 pm

Postby pskink » Wed Apr 07, 2010 2:37 pm

sblantipodi wrote:Ok, suppose that I don't want to support Android 1.5 and I don't want to put my images in
drawable-nodpi

is it possible to draw a not resized image on a canvas on a WVGA resolution using level4?
if yes, how?


you mean Bitmap which is not taken from any /res/* folder?
pskink
pskink
Master Developer
Master Developer
 
Posts: 719
Joined: Mon Nov 24, 2008 3:49 pm

Postby sblantipodi » Thu Apr 08, 2010 6:43 am

pskink wrote:
sblantipodi wrote:Ok, suppose that I don't want to support Android 1.5 and I don't want to put my images in
drawable-nodpi

is it possible to draw a not resized image on a canvas on a WVGA resolution using level4?
if yes, how?


you mean Bitmap which is not taken from any /res/* folder?


I mean bitmap that is taken from the standard drawable folder,
how can I draw a bitmap taken from this standard folder in an unresized way on Android 4 or later?
If I can do it, I can solve the problem of Level3 with an astract class that load dinamically the images on runtime.

So my questions is.
how can I draw a bitmap taken the standard drawable folder in an unresized way on Android 4 or later?
Thanks!!!!!
sblantipodi
Senior Developer
Senior Developer
 
Posts: 122
Joined: Fri Mar 26, 2010 1:41 pm

Postby pskink » Thu Apr 08, 2010 7:02 am

sblantipodi wrote:I mean bitmap that is taken from the standard drawable folder,
how can I draw a bitmap taken from this standard folder in an unresized way on Android 4 or later?
If I can do it, I can solve the problem of Level3 with an astract class that load dinamically the images on runtime.

So my questions is.
how can I draw a bitmap taken the standard drawable folder in an unresized way on Android 4 or later?
Thanks!!!!!


res = getResources()
opts.inScaled = false
bitmap = BitmapFactory.decodeResource(res, R.drawable.img, opts)

but i think that you cannot support both large screens and level3
pskink
pskink
Master Developer
Master Developer
 
Posts: 719
Joined: Mon Nov 24, 2008 3:49 pm

Postby sblantipodi » Thu Apr 08, 2010 7:06 am

pskink wrote:res = getResources()
opts.inScaled = false
bitmap = BitmapFactory.decodeResource(res, R.drawable.img, opts)

but i think that you cannot support both large screens and level3


Today I can't work on it because I need to work until this evening (here is 8:00AM),
this evening I will give you an answer but I think that I can do it without problem,
the answer is abstract class, abstract are magicians tool :D :D

In the meantime really thanks for your support.
sblantipodi
Senior Developer
Senior Developer
 
Posts: 122
Joined: Fri Mar 26, 2010 1:41 pm

Postby sblantipodi » Thu Apr 08, 2010 6:03 pm

I put this in the constructor:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. BitmapFactory.Options opts = new BitmapFactory.Options();
  2.  
  3. opts.inScaled = false;
  4.  
  5. logo = BitmapFactory.decodeResource(getResources(),
  6.  
  7.                     R.drawable.logo, opts);
Parsed in 0.030 seconds, using GeSHi 1.0.8.4


and this in the onDraw()

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. g.drawBitmap(logo, 0, 0, new Paint());
Parsed in 0.031 seconds, using GeSHi 1.0.8.4


The problem is.
logo.getWidth() returns the correct unscaled width, but when I draw it with drawBitmap()
it draws the scaled Bitmap. :shock:
sblantipodi
Senior Developer
Senior Developer
 
Posts: 122
Joined: Fri Mar 26, 2010 1:41 pm

Postby pskink » Thu Apr 08, 2010 6:33 pm

sblantipodi wrote:I put this in the constructor:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. BitmapFactory.Options opts = new BitmapFactory.Options();
  2. opts.inScaled = false;
  3. logo = BitmapFactory.decodeResource(getResources(),
  4.                     R.drawable.logo, opts);
Parsed in 0.035 seconds, using GeSHi 1.0.8.4


and this in the onDraw()

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. g.drawBitmap(logo, 0, 0, new Paint());
Parsed in 0.035 seconds, using GeSHi 1.0.8.4


The problem is.
logo.getWidth() returns the correct unscaled width, but when I draw it with drawBitmap()
it draws the scaled Bitmap. :shock:


what about


Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. g.drawBitmap(logo, 0, 0, null);
Parsed in 0.036 seconds, using GeSHi 1.0.8.4
pskink
pskink
Master Developer
Master Developer
 
Posts: 719
Joined: Mon Nov 24, 2008 3:49 pm

Top
Next

Return to SDK/ADT/Emulator Problems

Who is online

Users browsing this forum: No registered users and 9 guests