screen-orientation

Wrong display width and height in Android

巧了我就是萌 提交于 2019-12-03 14:29:05
I have a screen size of 600 (width) x 1024 (height). I get current width 600 but incorrectly get height 976 (without rotated screen). I get current width 1024 but wrong get height 552 (with rotated screen). int rowPixelWidth = ((WindowManager) getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay().getWidth(); int rowWidth = (int)Math.floor(rowPixelWidth / this.getResources().getDisplayMetrics().density); int rowPixelheight = ((WindowManager) getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay().getHeight(); int rowheight = (int)Math.floor(rowPixelheight / this.getResources()

Programmatically enabling/disabling screen rotations in Android

主宰稳场 提交于 2019-12-03 11:06:31
I have an app which displays a large amount of text for the user to read. I've found that when reading while lying down, I get annoyed that the screen rotates even though my head and the screen are aligned. I do not want to set this to be permanently in portrait mode, so I think this would preclude an approach of setting the android:screenOrientation="portrait" in the manifest. Ideally, I would like to enable/disable automatic orientation changes via a preference page. What would be my best approach? iandisme I would do this by having my preference page write to the SharedPreferences for my

Determining the Orientation of the screen rather than the orientation of the device

白昼怎懂夜的黑 提交于 2019-12-03 09:50:50
The [[UIDevice currentDevice] orientation] method returns a number of orientations beyond the portrait and landscape orientation. I am well aware of checking to see if the orientation returned is "valid", unfortunately if the orientation returned is NOT "valid" when my app requires a specific orientation to determine which methods to run, I have no way of knowing which method is appropriate. I have attempted a number of solutions to this, but for now the only thing I have been able to work out is to check to see if the orientation is LandscapeLeft or LandscapeRight and if it isn't I assume the

Gracefully handling screen orientation change during activity start

我的梦境 提交于 2019-12-03 09:32:23
I'm trying to find a way to properly handle setting up an activity where its orientation is determined from data in the intent that launched it. This is for a game where the user can choose levels, some of which are int portrait orientation and some are landscape orientation. The problem I'm facing is that setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE) doesn't take effect until the activity is fully loaded. This is a problem for me because I do some loading and image processing during startup, which I'd like to only have to do once. Currently, if the user chose a landscape

iPhone Safari CSS rotation bug

荒凉一梦 提交于 2019-12-03 09:05:07
I have a small mobile phone app that is acting strangely on the iPhone/Mobile Safari. The page renders and works great when it's orientation is vertical. When I rotate the phone horizontally some, but not all elements on the page resize correctly. Some header elements will stay nearly their same size, maybe increasing by 10%, others will double in size. Has anyone run into this? My first thought was that the css could have a mix of sizes based on ems and px's but finding every size element and converting them to em's didn't change a thing. Livingston Samuel It's because Mobile Safari on iPhone

Cordova ignores screen orientation lock [duplicate]

心不动则不痛 提交于 2019-12-03 08:24:23
This question already has an answer here: fix the orientation on page to landscape only in Jquery-mobile 3 answers I'm using Cordova 3.3.0 with my Galaxy S3 (running latest Cyanogenmod) to test an app I'm working on; I need the app screen to remain in "portrait" mode and be locked even if the user rotates the device. No matter what I tried or tutorials I followed, the app is ignoring the preferences to lock the screen. What am I doing wrong? Here's my config.xml: <?xml version='1.0' encoding='utf-8'?> <widget id="com.numediaweb.test" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns

Issue with pagination in UICollectionView when orientation changes

删除回忆录丶 提交于 2019-12-03 08:04:58
I'm preparing a GridView with all orientation support (height & width resizing) and paging enabled. In my sample in have taken a 3*3 Grid and to show it like that I have added some dummy transparent cell at the last page. The issue is when I'm at last page and there I'm changing my orientation from landscape to portrait the pagination doesn't work. I have used this code in willRotateToInterfaceOrientation : CGPoint scrollTo = CGPointMake(self.frame.size.width * mPageControl.currentPage, 0); [self setContentOffset:scrollTo animated:YES]; But still page moves to a page before the last page when

Lock screen Orientation to portrait - ios swift

我与影子孤独终老i 提交于 2019-12-03 05:56:30
I am creating an application with support only for portrait mode. I don't want Landscape or Portrait upside down. I tried some code. Which allows me to lock in portrait mode. I am using navigationcontroller and presentviewcontroller. Now my problem is: 1. If I rotate my device upside down and open my application it opens in upside down mode which is wrong. 2. I click some button and enter to presentviewcontroller it returns to portrait mode. I want all the navigationcontroller and presentviewcontroller in portrait mode My codes: I set device orientarion portrait in Target -> General ->

How to set orientation in nativescript

偶尔善良 提交于 2019-12-03 05:46:32
Hello I would like to know how to set device orientation in nativescript. Specifically I want the application that I am writing to stay in the same orientation (portrait) at all times so that rotating the device does not cause it to go into landscape. I tried the nativescript-orientation plugin and setOrientation. var orientation = require('nativescript-orientation'); console.log(JSON.stringify(orientation));// outputs JS: {} orientation.setOrientation("portrait"); However I get the error "Cannot read property setOrientation of undefined. tns plugin list shows that the plugin is installed.

Application crashes after screen orientation changed

对着背影说爱祢 提交于 2019-12-03 04:51:28
I've got the following problem. After starting, application works fine - even after changing the screen orientation. The application is not yet prepared to handle orientation change (eg. alternative layout and so on), so just the rotated default layout appears and it's OK. However, when I leave the application by pressing the back key, change the orientation and immediately after start the application again, it crashes. After a crash, if I start application once again, it works well until the previously described circumstances occur - then it crashes. I've connected the device to computer and