views:

44

answers:

2

Hi,

I'm currently working on a very simple aplication, and I intended to make it change the visual aspect depending on the screen size. The application just has 6 buttons like this:

http://www.freeimagehosting.net/uploads/e1efb4c4d0.jpg

I'm using the AbsoluteLayout, and changing the x and y of the buttons with the methods offsetLeftAndRight and offsetTopAndBottom. I'm not changing the layout of the buttons in the xml file, so the all start in the same place.

However, if I use this methods inside the onClickMethod they sometimes appear where I want them, sometimes don't (can't figure out why), but if i use them in the onCreate method, nothing happens.

Can someone point me in the right direction?

Thanks

+2  A: 

First off, you shouldn't use AbsoluteLayout. Specifying things by their exact pixel location is a recipe for trouble when you're dealing with screens of different sizes. It would be much better to use things like a LinearLayout, TableLayout or RelativeLayout with the right gravity settings to make it center.

Secondly, why why your methods to move the view elements are not doing anything in your onCreate: This is probably happening because your methods are getting called before the buttons are reading their size from the XML file. In other words, your changes are getting overriden by your XML settings before they are even displayed.

Lastly, we can't say much about why your methods to move them aren't working properly unless you show us the code. (Add it to your question rather than as a reply to this answer.)

Steve H
A: 

You are trying to do a Dashboard.

Check this out.

Macarse