views:

32

answers:

3

I have an application which is designed for a fixed screen size.But when i install the application on a device with different screen size ,i am not able to view the complete application. Is it possible to allow layout adjustments based on variable screen sizes? ... like setting width with some % of screen size which is decided when application installation is done For eg: 60% of screen size or 60% of relative layout

+1  A: 

Yes, this is actually very easy in Android: just dont declare a screen size, and let the OS handle it. The only time your screen is a fixed size is when you declare it as a fixed size. If you're having trouble, go back to the first tutorials from google. In their layouts, they never explicitly declare a screen size.

Hope this was helpful.

mtmurdock
I have not declared any screen size but while running my application with emulators of different sizes like 4 inches or 7 inches or any other value, the result varies.
shaireen
That's strange. I guess i would need to see your source to tell for sure.
mtmurdock
Sorry for this but I am able to do it with different size of emulators but not actual device of different screen sizes and resolution
shaireen
no i mean, post your source code so we can see it.
mtmurdock
Sorry bt i cant post my source code..
shaireen
A: 

My application is having a mapview and a relative layout on one screen..The width and height of mapview have been fixed like 300 px and 500px..This way the relative layout is not visible on device as device has screen size of 3 inches. What i wanna ask is that, Is dere any way that i can see mapview as well as layout together on any screen size without the need of fixing it again and again..like the application finds the screen size whle installation and adjusts accordingly.

shaireen
+1  A: 

You can find out about the size of the screen by using getWindowManager().

So, for example, to find out what 60% of your screen width is you could do this in your onCreate() method:

DisplayMetrics dm = new DisplayMetrics(); 
getWindowManager().getDefaultDisplay().getMetrics(dm); 
int sixtyPercentScreenWidth = (int) Math.round(dm.widthPixels * 0.6);
Sotapanna