Questions tagged [screen-orientation]
Detects whether the screen is in portrait orientation (height > width) or landscape orientation (width > height), and switches between the two. This term is especially used in mobile devices, where applications are notified when the user rotates the device.
                                	
	screen-orientation
    
                            
                        
                    
            1,595
            questions
        
        
            429
            votes
        
        
            10
            answers
        
        
            311k
            views
        
    I want my android application to be only run in portrait mode?
                I want my android application to be only run in portrait mode?
How can I do that?
            
        
       
    
            361
            votes
        
        
            28
            answers
        
        
            138k
            views
        
    How do I change screen orientation in the Android emulator?
                How do we change emulator screen orientation to landscape or portrait?
            
        
       
    
            269
            votes
        
        
            10
            answers
        
        
            115k
            views
        
    How to prevent custom views from losing state across screen orientation changes
                I've successfully implemented onRetainNonConfigurationInstance() for my main Activity to save and restore certain critical components across screen orientation changes. 
But it seems, my custom views ...
            
        
       
    
            224
            votes
        
        
            15
            answers
        
        
            107k
            views
        
    Android: allow portrait and landscape for tablets, but force portrait on phone?
                I would like tablets to be able to display in portrait and landscape (sw600dp or greater), but phones to be restricted to portrait only. I can't find any way to conditionally choose an orientation. ...
            
        
       
    
            183
            votes
        
        
            14
            answers
        
        
            162k
            views
        
    Flutter: How to set and lock screen orientation on-demand
                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. ...
            
        
       
    
            127
            votes
        
        
            8
            answers
        
        
            180k
            views
        
    Change Screen Orientation programmatically using a Button
                I think this is implementable since screen rotation behaviour can go up to the application level.
            
        
       
    
            126
            votes
        
        
            18
            answers
        
        
            87k
            views
        
    Android: Temporarily disable orientation changes in an Activity
                My main activity has some code that makes some database changes that should not be interrupted. I'm doing the heavy lifting in another thread, and using a progress dialog which I set as non-...
            
        
       
    
            77
            votes
        
        
            10
            answers
        
        
            32k
            views
        
    In AndroidManifest: Expecting android:screenOrientation="unspecified"
                Android Studio 3.6.
I want my app to be always in portrait mode. So in my AndroidMainfest.xml:
<activity
   android:name=".activity.SplashActivity"
   android:screenOrientation="portrait">
   &...
            
        
       
    
            59
            votes
        
        
            8
            answers
        
        
            62k
            views
        
    How do I get the CURRENT orientation (ActivityInfo.SCREEN_ORIENTATION_*) of an Android device?
                I would like to find out the detailed orientation of a device, preferably one of SCREEN_ORIENTATION_LANDSCAPE, SCREEN_ORIENTATION_PORTRAIT, SCREEN_ORIENTATION_REVERSE_LANDSCAPE, ...
            
        
       
    
            53
            votes
        
        
            17
            answers
        
        
            86k
            views
        
    React Native: Different styles applied on orientation change
                I'm developing a React Native application to be deployed as a native application on iOS and Android (and Windows, if possible).
The problem is that we want the layout to be different depending on ...
            
        
       
    
            53
            votes
        
        
            5
            answers
        
        
            85k
            views
        
    i want to make my application only in landscape in android
                I want to make my app work only in landscape mode but can't make it work. I have given screenOrientation = "landscape" even though the first page will be in landscape mode and other activity will be ...
            
        
       
    
            51
            votes
        
        
            7
            answers
        
        
            52k
            views
        
    Responsive site is zoomed in when flipping between Portrait and Landscape on iPad/iPhone
                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 ...
            
        
       
    
            51
            votes
        
        
            6
            answers
        
        
            92k
            views
        
    Will $(window).resize() fire on orientation change?
                Im using this to run some code when a browser window is resized: $(window).resize(callback)
I also need to run this code when the orientation is changed in phones and tablets. Will the above fire on ...
            
        
       
    
            49
            votes
        
        
            2
            answers
        
        
            5k
            views
        
    Why has `android:screenOrientation="behind"` no effect in android 4.1.2?
                As a test sample, there is an application with 2 activities: MainActivity that launches SecondActivity on button click.
It works fine on Android 4.0.4, but on Android 4.1.2 I encountered unexpected ...
            
        
       
    
            41
            votes
        
        
            8
            answers
        
        
            48k
            views
        
    Alternative iOS layouts for portrait and landscape using just one .xib file
                Using interface builder in xcode and just one .xib file, how can I create alternate layouts when rotating between landscape and portrait orientations?
See diagram of differing layouts
N.b. the green ...
            
        
       
    
            34
            votes
        
        
            5
            answers
        
        
            43k
            views
        
    PhoneGap - Forcing Landscape orientation
                I started looking into PhoneGap yesterday and created a simple "marble" rolling around while tilting the phone. I am currently developing on Android but I want the orientation to stay as landscaping ...
            
        
       
    
            34
            votes
        
        
            6
            answers
        
        
            24k
            views
        
    iphone/ipad orientation handling
                This is more of a general question for people to provide me guidance on, basically Im learning iPad/iPhone development and have finally come across the multi-orientation support question.
I have ...
            
        
       
    
            33
            votes
        
        
            4
            answers
        
        
            43k
            views
        
    Detect iPad orientation change
                How to detect with javascript or jquery when user turns iPad from vertical position to horizontal or from horizontal to vertical?
            
        
       
    
            32
            votes
        
        
            7
            answers
        
        
            14k
            views
        
    Get phone orientation but fix screen orientation to portrait
                I want to get the phone orientation but keep the screen orientation to portrait.
So no matter the user turns the phone to landscape or portrait, the view stays the same, but I can get whether it is ...
            
        
       
    
            32
            votes
        
        
            5
            answers
        
        
            44k
            views
        
    Change screen orientation in Android without reloading the activity
                I want to change the orientation programmatically while running my Android App, with these lines of code:
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);  
setRequestedOrientation(...
            
        
       
    
            31
            votes
        
        
            5
            answers
        
        
            19k
            views
        
    iPhone - UIWindow rotating depending on current orientation?
                I am adding an additional UIWindow to my app.
My main window rotates correctly, but this additional window I have added does not rotate.
What is the best way to rotate a UIWindow according to the ...
            
        
       
    
            31
            votes
        
        
            2
            answers
        
        
            12k
            views
        
    Android screenorientation change for all activities
                I want to fix screen orientation on my android application to portrait. Using google, i've found, that this can be done by adding the following code to my manifest.xml:
<activity android:name="....
            
        
       
    
            30
            votes
        
        
            10
            answers
        
        
            62k
            views
        
    How to get current orientation of device programmatically in iOS 6?
                I have developed an iOS App and tested it on iOS6 device. While testing, I realized that my App is not responding to Orientation changes as expected.
Here is my Code:
// Autorotation (iOS >= 6.0)
...
            
        
       
    
            30
            votes
        
        
            6
            answers
        
        
            36k
            views
        
    shouldAutorotateToInterfaceOrientation is not working in iOS 6
                In iOS 6, shouldAutorotateToInterfaceOrientation is not working, but it worked fine in iOS 5.0 and 5.1.
What do I need to change for iOS 6? Here is my code:
- (BOOL)...
            
        
       
    
            28
            votes
        
        
            3
            answers
        
        
            18k
            views
        
    How do you force an orientation change in an Android Instrumentation test?
                I'm writing some acceptance tests for an application using the ActivityInstrumentationTestCase2 class. I want to cause an orientation change from within the test to ensure that a number of things ...
            
        
       
    
            26
            votes
        
        
            3
            answers
        
        
            25k
            views
        
    iPhone Storyboard: different scene for portrait and landscape
                If you scroll down a bit at this Apple Developer Page you'll find the section "Creating an Alternate Landscape Interface". The basic approach described there is to present a different NIB file as a ...
            
        
       
    
            25
            votes
        
        
            5
            answers
        
        
            17k
            views
        
    How to change the orientation of the iPad simulator?
                How can we change the orientation of the iPad simulator?
For the Android tablet simulators the Ctrl + F12 combination is used to change the orientation from portrait to landscape, similarly what is ...
            
        
       
    
            25
            votes
        
        
            1
            answer
        
        
            31k
            views
        
    How can I use SensorManager.getOrientation for tilt controls like "My Paper Plane"?
                The Android game My Paper Plane is a great example of how to implement tilt controls, but I've been struggling to understand how I can do something similar.
I have the following example that uses ...
            
        
       
    
            24
            votes
        
        
            5
            answers
        
        
            44k
            views
        
    Android: Detect Orientation Changed
                I need to detect an orientation change in my application, but I don't want my layout to be changed from portrait to landscape.
Currently I'm using the OrientationEventListener however detecting the ...
            
        
       
    
            23
            votes
        
        
            4
            answers
        
        
            19k
            views
        
    How do I use a service to monitor Orientation change in Android
                I'm writing a Widget that will display a countdown timer.  I have the widget working the way I want it until I flip the phone from landscape to portrait.  My widget does not update and goes to it's ...
            
        
       
    
            22
            votes
        
        
            4
            answers
        
        
            10k
            views
        
    How do you force a configuration change in an Android Robolectric test?
                I'm using robolectric to make my android unit tests fast enough to be useful.  I want to test that code I've written works while the screen orientation is changing to simulate a common real world use ...
            
        
       
    
            22
            votes
        
        
            4
            answers
        
        
            14k
            views
        
    "viewWillTransitionToSize:" not called in iOS 9 when the view controller is presented modally
                I present a view controller from another one:
- (void)showModalView
{
   UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
   MySecViewController *mySecViewController = ...
            
        
       
    
            20
            votes
        
        
            3
            answers
        
        
            21k
            views
        
    Activity in portrait or reverse portrait only
                I want my activity to be available only in both portrait modes - portrait and reversePortrait. How can I achieve this? When I set android:screenOrientation="portrait" it will force activity to be only ...
            
        
       
    
            20
            votes
        
        
            1
            answer
        
        
            15k
            views
        
    Determining the Orientation of the screen rather than the orientation of the device
                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 "...
            
        
       
    
            19
            votes
        
        
            2
            answers
        
        
            35k
            views
        
    Avoid reloading activity with asynctask on orientation change in android
                How do I avoid reloading the activity with asynctask class in activity when the user changes orientation, in android? Can anybody give an example?
            
        
       
    
            19
            votes
        
        
            2
            answers
        
        
            30k
            views
        
    Javascript screen orientation on safari
                I'm trying to make a responsive web site and it is almost finished, but I need a hand.
I'm using this example to know the angle:
    angulo = screen.orientation || screen.mozOrientation || screen....
            
        
       
    
            19
            votes
        
        
            4
            answers
        
        
            17k
            views
        
    How to fix screen orientation to portrait for my whole PhoneGap app
                How to configure the Phonegap app to be fixed to only portrait mode, I there any possibility to do it with CSS or JavaScript so that I should be able to get the consistent behaviour across the ...
            
        
       
    
            19
            votes
        
        
            5
            answers
        
        
            16k
            views
        
    Android SensorManager strange how to remapCoordinateSystem
                API Demos -> Graphics -> Compass
It works properly only, until you don't change the device natural orientation.
In most phones is the portrait and most 10 inch tablets are the landscape. If you ...
            
        
       
    
            19
            votes
        
        
            2
            answers
        
        
            8k
            views
        
    Android Rotation Landscape Only
                I'm writing an application for an Android Tablet. I want the ScreenOrientation always to be in "Landscape", but the app should be able to rotate 180°. If you hold the Tablet upside down, the View ...
            
        
       
    
            19
            votes
        
        
            3
            answers
        
        
            15k
            views
        
    Replacing fragments and orientation change
                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 (...
            
        
       
    
            19
            votes
        
        
            5
            answers
        
        
            14k
            views
        
    screen.width/screen.height not updating after screen rotation
                I'm experiencing this problem on an iPhone device (iPhone 7, iOS 10, but also other iPhones too): in javascript, if I intercept the orientationchange event, inside the handler, screen.width and screen....
            
        
       
    
            18
            votes
        
        
            5
            answers
        
        
            36k
            views
        
    shouldAutorotateToInterfaceOrientation doesn't work
                I've been writing my Universal application in portrait mode, 
and now after about 15 nib files, many many viewCotnrollers,
I'd like to implement the shouldAutorotateToInterfaceOrientation and design ...
            
        
       
    
            18
            votes
        
        
            3
            answers
        
        
            25k
            views
        
    Lock screen Orientation to portrait - ios swift
                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 ...
            
        
       
    
            18
            votes
        
        
            1
            answer
        
        
            5k
            views
        
    Orientation change in Honeycomb
                I have an activity that shouldn't be recreated after an orientation change. I added the following to the activity declaration in the manifest:
android:configChanges="orientation"
On Android 2.3 this ...
            
        
       
    
            18
            votes
        
        
            4
            answers
        
        
            10k
            views
        
    How do I lock screen orientation for phone, but not for tablet? (Android)
                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 ...
            
        
       
    
            18
            votes
        
        
            1
            answer
        
        
            18k
            views
        
    Difference between SCREEN_ORIENTATION_USER and SCREEN_ORIENTATION_SENSOR
                While developing an Android app, I've found two ActivityInfo attributes for setting the screen orientation.
The attributes having USER are as follows:
SCREEN_ORIENTATION_USER
...
            
        
       
    
            17
            votes
        
        
            4
            answers
        
        
            12k
            views
        
    How to set orientation in nativescript
                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 ...
            
        
       
    
            17
            votes
        
        
            3
            answers
        
        
            4k
            views
        
    why does the gingerbread emulator orientation get stuck in apps?
                At first I thought this was a problem with my app, but it seems to be happening in any app (though interestingly, not the home screen) in the gingerbread emulator.
To replicate my issue, open eclipse ...
            
        
       
    
            17
            votes
        
        
            1
            answer
        
        
            7k
            views
        
    Is the setDisplayOrientation sample code correct?
                The documentation page for Camera.setDisplayOrientation contains the following code sample stating that using it will "make the camera image show in the same orientation as the display":
 public ...
            
        
       
    
            16
            votes
        
        
            2
            answers
        
        
            23k
            views
        
    Android. Lock orientation of screen for all Activities [duplicate]
                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. ...