screen-orientation

How to catch DOMException in Chrome?

痴心易碎 提交于 2019-12-22 04:12:26
问题 I get this error: Uncaught (in promise) DOMException: lockOrientation() is not available on this device. code: 9 message: "lockOrientation() is not available on this device." name: "NotSupportedError" when I run the following code in Chrome: try { screen.orientation.lock('portrait'); } catch (error) { // whatever } The fact that the error is being thrown is expected, since Desktop Chrome doesn't support orientation locking. I'd like to catch the error so it doesn't litter the console, but

Android: set activity orientation BEFORE onCreate, but not in manifest (HDMI plugged in issue)

北城余情 提交于 2019-12-21 21:27:34
问题 I can perfectly manage orientation change programatically, by using setRequestedOrientation in onCreate . Everything works really fine, until I plug a HDMI cable. After this, the tablet "wants" to be in landscape mode. So when I open an activity, it shows first in "landscape" and then right after it shows in "portrait", (because I'm calling setRequestedOrientation(variable_with_orientation_desired_by_the_user) where variable=ActivityInfo.SCREEN_ORIENTATION_PORTRAIT in onCreate As you can "see

How to set screen-orientation for other apps?

巧了我就是萌 提交于 2019-12-21 19:58:09
问题 With the following lines we can set the orientation with in the application.. setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); If I want to set the orientation to every screen(not only with in application). how can i do this? Any help. Thanks in advance 回答1: setRequestedOrientation(0); or setRequestedOrientation(1); horizontal (landscape) - 0 vertical (potrait) - 1 You can try this. Or you can try it in your

Wrong display width and height in Android

£可爱£侵袭症+ 提交于 2019-12-21 04:46:14
问题 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))

Issue with pagination in UICollectionView when orientation changes

无人久伴 提交于 2019-12-21 02:28:10
问题 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);

Application crashes after screen orientation changed

半世苍凉 提交于 2019-12-20 16:50:33
问题 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

Application crashes after screen orientation changed

萝らか妹 提交于 2019-12-20 16:50:16
问题 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

Repositioning controls when the orientation changes

不问归期 提交于 2019-12-20 10:35:19
问题 I know Auto Layout can be used to make the sizes and position consistent when the orientation changes. Is it possible to completely change the layout when the orientation changes? For example, please look at the below wire-frame of a simple login screen in portrait mode. Now if I rotate the device, I want to completely re-position the controls. Can this kind of a thing be done by using Auto Layout? If not, how should I go about this? Thank you. 回答1: In your case it can be achieved by two

Freeze screen orientation

≯℡__Kan透↙ 提交于 2019-12-20 03:21:13
问题 There is CheckBox with following code: CheckBox cb = (CheckBox)findViewById(R.id.freezer); cb.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (isChecked) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_NOSENSOR); } else { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR); } } }); So, when i check it, screen is rotated to default system orientation

Freeze screen orientation

最后都变了- 提交于 2019-12-20 03:21:08
问题 There is CheckBox with following code: CheckBox cb = (CheckBox)findViewById(R.id.freezer); cb.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (isChecked) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_NOSENSOR); } else { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR); } } }); So, when i check it, screen is rotated to default system orientation