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.

With the advancement of Mobile devices (including mobile phones, tablets, phablets, etc.) It became the implicit requirement of the user to have an application which can work both in landscape as well as portrait orientation. The screen-Orientation deals with the screens of mobile devices.

Questions related to managing applications while orientation change can be a part of this tag wiki.

1595 questions
423
votes
10 answers

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?
James
  • 13,891
  • 26
  • 68
  • 93
361
votes
28 answers

How do I change screen orientation in the Android emulator?

How do we change emulator screen orientation to landscape or portrait?
detj
  • 5,299
  • 6
  • 30
  • 32
269
votes
10 answers

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 are being re-created from scratch when the…
Brad Hein
  • 10,997
  • 12
  • 51
  • 74
219
votes
14 answers

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. Any suggestions?
Kenny Wyland
  • 20,844
  • 26
  • 117
  • 229
173
votes
14 answers

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. Anyone know how to do this? I would like it to…
Jus10
  • 14,519
  • 21
  • 52
  • 77
127
votes
8 answers

Change Screen Orientation programmatically using a Button

I think this is implementable since screen rotation behaviour can go up to the application level.
Sam
  • 4,521
  • 13
  • 46
  • 81
126
votes
18 answers

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-cancellable. However, I noticed that if I rotate my phone…
Christopher Perry
  • 38,891
  • 43
  • 145
  • 187
77
votes
10 answers

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:
Alexei
  • 14,350
  • 37
  • 121
  • 240
59
votes
8 answers

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, SCREEN_ORIENTATION_REVERSE_PORTRAIT from ActivityInfo or…
Zoltán
  • 21,321
  • 14
  • 93
  • 134
53
votes
16 answers

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 screen dimensions and its orientation. I've made some…
Unapedra
  • 2,043
  • 4
  • 25
  • 42
53
votes
5 answers

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 in portrait. XML FILE
shripal
  • 1,222
  • 4
  • 19
  • 40
51
votes
7 answers

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 site is zoomed in instead of adapting to the screen…
50
votes
6 answers

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 this event?
Evanss
  • 23,390
  • 94
  • 282
  • 505
46
votes
2 answers

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 behaviour. AutoRotation in system settings is off…
41
votes
8 answers

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 view/area would contain 3 items flowing…
Dave Haigh
  • 4,369
  • 5
  • 34
  • 56
1
2 3
99 100