I am converting and android handset application to tablet (1024*600 and 1280*720). I have given the support for different screen- size, but stuck in orientation part. I want some pages to be visible as landscape. For example after logged in by user the next intent should be in landscape form. After searching I found clue but not very understandable answer such as
By adding activity in manifest.xml file
At runtime by using getOrientation().
Thanks
The question is not clear, if you're forcing screen orientation by size (eg on tablet device there's only landscape orientation), i think you should get the screen width and height first then evaluate it. If the screen width and height are 1024*600 or 1280*720, you change the orientation with setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
To get the width and height, do this in your activity:
Display display = getWindowManager().getDefaultDisplay();
int width, height;
try {
Point size = new Point();
display.getSize(size);
width = size.x;
height = size.y;
}
catch (NoSuchMethodError e) {
width = display.getWidth();
height = display.getHeight();
}
See this
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.