There are many tutorials around on web which tells how to support different screen sizes in android. But there are many tiny little real problems which comes in every day life of android developer while supporting different screen size.
Well I understand we can create different layouts & values for different screen sizes which will ensure my screen is properly scaled and fits properly in different screen size. It also ensures the flexibility of amount of information being displayed on different screen size.
Now if we want the application to appear in portrait on small & normal screen sizes, but if the screen is large or xlarge we want the application to appear in landscape, then how do we go about it?
At first I thought that probably defining different screen orientation in different value folder will get this done. But unfortunately it does not work on all android devices.
So the only method left for us to achieve different screen orientation on different screen size is programmatic.
What we need to do is – at the time of activity creation, get the screen size and accordingly set the orientation.
int layout = getResources().getConfiguration().screenLayout
& Configuration.SCREENLAYOUT_SIZE_MASK;
if (layout == Configuration.SCREENLAYOUT_SIZE_XLARGE
|| layout == Configuration.SCREENLAYOUT_SIZE_LARGE) {
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
} else {
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
}
Tagged: Android, Android Multiple Screen Size, Android Supporting Different Size, Android Tutorial, Development
Seems to fail
http://stackoverflow.com/questions/11703742/some-devices-ignore-string-resource-in-manifest-parse-error
Came here after hitting this problem
Thanks for pointing.. Looks like these steps doesn’t work on all device. Will be editing this post pretty soon.
DRAG and DROP on android. need help please, im new to android .. i want to display the description of the item that being drop .. for example, in this link : when i trash the dog1 , in other textfield will display “dog1 deleted” .
http://capdroid.wordpress.com/2012/07/18/android-drag-and-drop_tutorial/
help please ! :\ thanks in advance .
Updated the post. Hope it will be helpful.
I have been going around in circles trying so resolve this problem. Your solution is not suitable for API 3. Do you have a work-a-round?