screen-orientation

Set the orientation to portrait from code

不想你离开。 提交于 2019-12-20 03:19:50
问题 I know I can limit the orientation from the manifest file. Like this android:screenOrientation="portrait" But is it possible to set the orientation from code ? for example setting the activity to full screen can be done both from manifest and from code this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); 回答1: setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); 回答2: Activity. setRequestedOrientation(..) 来源: https:/

Unity Cardboard Orientation Landscape Right Upside Down

允我心安 提交于 2019-12-20 02:37:14
问题 Hi I have a Unity app which uses google Cardboard SDK to enable stereoscopic view so I will have a VR enabled app. My app runs perfectly fine. But there is a problem if I set the player settings orientation to be auto orientation with only landscape left and landscape right allowed. When it is in landscape left, everything works as per normal but when it is in landscape right the cardboard view will turn 180 degrees (settings button moved to bottom of screen) but my unity objects does not.

Android. Lock orientation of screen for all Activities [duplicate]

荒凉一梦 提交于 2019-12-19 05:18:58
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: How can I set Orientation Fixed for all activities I would like to lock my screen orientation for my app. I mean that all Activities must have the same landscape orientation. I don't want to add android:screenOrientation="portrait" in the manifest for all activities. Is there any other way? thanks Regards 回答1: You have two options for achieving the result. You can specify per activity base orientation

how to implement onRetainNonConfigurationInstance

蹲街弑〆低调 提交于 2019-12-19 02:39:53
问题 i made a media player in android it's working great but when i change the screen orientation, the activity is being restarted i know that this question was already asked on stackoverflow several times but none of the answers helped me. i think i should use: onRetainNonConfigurationInstance @Override public Object onRetainNonConfigurationInstance() { ... } but i didn't know the correct way to implement it so if someone could give me a tutorial or an implicit example i would be grateful 回答1: I

How do I lock screen orientation for phone, but not for tablet? (Android)

北战南征 提交于 2019-12-18 19:06:20
问题 I have been working on a Android project, that is intended to be compatible with both the Android phones and tablets. On the tablet the app is working great and looks good too. However, on the phone we have been running into issues both programmatically and layout wise (working with a 10.1 inch screen is a lot easier than a 4 inch screen). To solve some of these problems we have decided to deactivate screen orientation but only for the phone version, atleast temporarily. The question is

Replacing fragments and orientation change

我的梦境 提交于 2019-12-18 11:06:32
问题 I'm developing an Android application targeting 2.x and 3.0 devices and thus I'm using the compatibilty API. I'm testing on Android 2.0. I'm trying to replace a displayed fragment with another one (search form with search results) and I'm experiencing a crash on orientation change when the second (results) fragment is displayed. Basically, I have an activity, that includes a fragment defined in layout xml as <fragment class="org.prevoz.android.search.SearchFormFragment" android:id = "@+id

Android: Keep MediaPlayer running during Activity screen orientation update

北城余情 提交于 2019-12-18 04:46:20
问题 I use a MediaPlayer to play an MP3. Currently I disabled screen orientation changes by using android:screenOrientation="portrait" android:configChanges="keyboardHidden|orientation" in the manifest. I do want to support landscape mode now - i.e. removed those tags - but have the problem that during the destroy/create cycle the player gets stopped and then restarted. This is okay and I actually do this even manually in onPause() to stop the player when the activity goes in the background. To

Flutter: How to set and lock screen orientation on-demand

浪子不回头ぞ 提交于 2019-12-17 21:55:37
问题 On one of my flutter pages, I need the screen to set to landscape mode and lock it so it can't rotate into portrait mode, but only on the one page. So need a way to enable this function on-the-fly. Anyone know how to do this? I would like it to rotate landscape-left or landscape-right, just not into portrait mode. 回答1: First import the services package: import 'package:flutter/services.dart'; This will give you access to the SystemChrome class, which "Controls specific aspects of the

What is the best way to detect orientation in an app extension?

假装没事ソ 提交于 2019-12-17 18:53:14
问题 What is the best way to detect a device's orientation in an application extension? I have had mixed results with solutions I've found on here: How to detect Orientation Change in Custom Keyboard Extension in iOS 8? Get device current orientation (App Extension) I have looked at size classes and UITraitCollection and found that the device inaccurately reports that it is in portrait when it is in fact in landscape (not sure if this is OS bug, or I am not querying the right APIs the right way).

Responsive site is zoomed in when flipping between Portrait and Landscape on iPad/iPhone

回眸只為那壹抹淺笑 提交于 2019-12-17 17:35:39
问题 I've built a responsive site using Twitter Bootstrap here: http://zarin.me/cce/ The responsive design works great on iPad and iPhone, however when I flip the device from portrait to landscape, the site is zoomed in instead of adapting to the screen (pinching the screen works). What am I missing? Is this a viewport issue? Here's the only viewport code I have in my : <meta content="width=device-width, initial-scale=1.0" name="viewport"> Thanks in advance! 回答1: You also want to add the maximum