0

i want to scale my android application, basically i developed it for 800x480 display with a AbsoluteLayout. This is necessary for my Application, i can't change it.

Now the Problem: When i start my app in the Emulator the buttons disappear and the images are extremly large. I thought android would scale applications with a fixed size down by default, but it does not work. I already tried to manipulate the manifest but this did not work.

I use a ImageView component for graphics. Targeting Android 2.1

Cheers Felix

Felix K.
  • 6,201
  • 2
  • 38
  • 71
  • You can change it and you should change it. If you think you have to use AbsoluteLayout, it is very possible, that you haven't studied different layout types enough. – peter.bartos Sep 25 '11 at 14:01
  • The design is given by a designer, its a pure graphically layout, each button is a image. – Felix K. Sep 25 '11 at 15:01
  • --- Could not edit the comment before --- The design is done by a designer which actually is not made for beeing flexible for other sizes than 800x480, its a pure graphically layout, each button is a image and i have a background for each activity. Anyway other layouts like RelativeLayout bring the same problem to my app, the button ( ImageView ) is not scaled down to fit into the app. – Felix K. Sep 25 '11 at 15:08

1 Answers1

1

It is definitely not ideal to use AbsoluteLayout. But, if you want to just push through with it, you should switch the units of all your co-ordinates and sizes away from px (pixels) to dp (density independent pixels). You will have to scale all of your existing co-ordinates by a factor of 2/3 to start, since 1 dp = 1.5px at the density that your layout targets (hdpi).

You will need to explicitly specify the sizes of all your images and layouts. If, for example, you had a button that was 30px wide and 120px tall, then it will become 20dp wide and 80dp tall.

Of course, the images won't look great on smaller (mdpi) screens, since they will be scaled to 2/3 size. Also, some devices are fixed to landscape mode, where you will definitely encounter layout problems. So it's not pretty, but it may get you over the finish line, depending on your requirements.

pents90
  • 1,782
  • 17
  • 17
  • Thank you for your reply. I have now all units in dp and the images too. The image seems to have the right size now, which is one step forward, but the image ( button ) is still at the wrong location. It seems that android is moving the image to coordinates which are twice as large than the original coordinates. The layout size is still "fill_parent", because when i tried to set it to absolute dp it is to large to fit the display. – Felix K. Sep 25 '11 at 19:36
  • At least i found out that i need to resize the layout to 2/3 of the original size too, but the layout is still a bit to large and does not match the emulator image. – Felix K. Sep 25 '11 at 19:52
  • So you reduced your location co-ordinates to 2/3 of the original co-ords, right? So, if you had something at x=60px, y=18px, it would now be at x=40dp and y=12dp, right? – pents90 Sep 25 '11 at 20:00
  • Yes. Location and size values. So id modified the screen size of the layout to 533dp/320dp, but it still is to large to fit the emulator screen. I'm wondering that android does not scales the app to the bounds. – Felix K. Sep 26 '11 at 07:46
  • Works now, was the right way, just need to add something for the removal of the title-bar. – Felix K. Sep 27 '11 at 06:16