Questions tagged [orientation]
Orientation is the way up, down, left or right something is facing or being held in. Typically, you distinguish between Portrait (or Vertical) and Landscape (or Horizontal) orientations.
orientation
4,165
questions
472
votes
24
answers
315k
views
Check orientation on Android phone
How can I check if the Android phone is in Landscape or Portrait?
352
votes
24
answers
238k
views
Flutter: how to prevent device orientation changes and force portrait?
I would like to prevent my application from changing its orientation and force the layout to stick to "portrait".
In the main.dart, I put:
void main(){
SystemChrome.setPreferredOrientations([
...
327
votes
12
answers
274k
views
Force "portrait" orientation mode
I'm trying to force the "portrait" mode for my application because my application is absolutely not designed for the "landscape" mode.
After reading some forums, I added these lines in my manifest ...
241
votes
9
answers
188k
views
How can I get the current screen orientation?
I just want to set some flags when my orientation is in landscape so that when the activity is recreated in onCreate() i can toggle between what to load in portrait vs. landscape. I already have a ...
237
votes
8
answers
68k
views
Background task, progress dialog, orientation change - is there any 100% working solution?
I download some data from internet in background thread (I use AsyncTask) and display a progress dialog while downloading. Orientation changes, Activity is restarted and then my AsyncTask is completed ...
186
votes
18
answers
90k
views
Is [UIScreen mainScreen].bounds.size becoming orientation-dependent in iOS8?
I ran the following code in both iOS 7 and iOS 8:
UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation];
BOOL landscape = (orientation == ...
163
votes
13
answers
278k
views
How do I lock the orientation to portrait mode in a iPhone Web Application?
I'm building a iPhone Web Application and want to lock the orientation to portrait mode. is this possible? Are there any web-kit extensions to do this?
Please note this is an application written in ...
162
votes
3
answers
326k
views
Lock screen orientation (Android) [duplicate]
I'm writing an android application that uses tabs with different contents (activities).
In one of these activities, I would like to lock the screen orientation to "Landscape"-mode,
but in the other ...
160
votes
11
answers
189k
views
How do I specify different layouts for portrait and landscape orientations?
I've seen references to being able to specify two separate layout xml files for an activity, one for Portrait and one for Landscape. I've not been to find any information on how to do that though. ...
154
votes
20
answers
107k
views
Android WebView: handling orientation changes
The issue is the performance following rotation. The WebView has to reload the page, which can be a bit tedious.
What's the best way of handling an orientation change without reloading the page from ...
132
votes
6
answers
188k
views
Android: alternate layout xml for landscape mode
How can I have one layout for landscape and one for portrait? I want to assume extra width and conserve vertical space when the user rotates the phone over sideways.
127
votes
8
answers
103k
views
Android - Camera preview is sideways
I am using a Preview to display what the camera see's on the screen.
I can get everything working fine, surface created, surface set and the surface is displayed.
However it always displays the ...
126
votes
7
answers
106k
views
Android Fragment lifecycle over orientation changes
Using the compatibility package to target 2.2 using Fragments.
After recoding an activity to use fragments in an app I could not get the orientation changes/state management working so I've created a ...
110
votes
7
answers
81k
views
How to lock orientation during runtime
Is there a way to lock orientation during runtime? For example I'd like to allow the user to lock the screen to landscape if the user currently in landscape and toggle the menu option.
109
votes
4
answers
48k
views
Android phone orientation overview including compass
I've been trying to get my head around the Android orientation sensors for a while.
I thought I understood it. Then I realised I didn't. Now I think (hope) I have a better feeling for it again but I ...
107
votes
5
answers
74k
views
What is the "right" way to handle orientation changes in iOS 8?
Can someone please tell me the "right" or "best" approach to working with portrait and landscape interface orientations in iOS 8? It seems that all the functions I want to use for that purpose are ...
101
votes
11
answers
119k
views
How do I reset the scale/zoom of a web app on an orientation change on the iPhone?
When I start my app in portrait mode, it works fine. Then I rotate into landscape and it's scaled up. To get it to scale correctly for the landscape mode I have to double tap on something twice, ...
101
votes
15
answers
83k
views
Camera orientation issue in Android
I am building an application that uses camera to take pictures. Here is my source code to do this:
File file = new File(Environment.getExternalStorageDirectory(),
imageFileName);
...
97
votes
20
answers
117k
views
Getting device orientation in Swift
I was wondering how I can get the current device orientation in Swift? I know there are examples for Objective-C, however I haven't been able to get it working in Swift.
I am trying to get the device ...
97
votes
6
answers
107k
views
Layout orientation in code
I have this code in my application:
LinearLayout.LayoutParams params =
new LinearLayout.LayoutParams(WRAP_CONTENT, WRAP_CONTENT);
and I just want to set the orientation of the LinearLayout to ...
91
votes
7
answers
185k
views
How to set Android camera orientation properly?
I want to set the camera orientation according to the device orientation in Android but nothing seems to be working. I tried to rotate the Surface as well as the camera parameters but the camera ...
88
votes
13
answers
113k
views
PHP read_exif_data and Adjust Orientation
I am using the following code to rotate an uploaded jpeg image if the orientation is off. I am only having problems with images uploaded from iPhones and Android.
if(move_uploaded_file($_FILES['...
86
votes
14
answers
118k
views
iOS - UIImageView - how to handle UIImage image orientation
Is it possible to setup UIImageView to handle image orientation? When I set the UIImageView to image with orientation RIGHT (it is photo from camera roll), the image is rotated to right, but I want to ...
86
votes
7
answers
67k
views
Android, how to not destroy the activity when I rotate the device?
I have an app that works only in portrait mode, and I have made the changes in my manifest file for every activity the orientation to be portrait. But when I rotate the device, the activity recreates ...
78
votes
9
answers
75k
views
How to detect orientation change in layout in Flutter?
How to find out Orientation is portrait or landscape in Flutter
if(portrait){
return ListView.builder()
}else{
return GridView.count()
}
76
votes
9
answers
60k
views
Detecting iOS UIDevice orientation
I need to detect when the device is in portrait orientation so that I can fire off a special animation. But I do not want my view to autorotate.
How do I override a view autorotating when the device ...
72
votes
13
answers
103k
views
How Do I detect the orientation of the device on iOS?
I have a question on how to detect the device orientation on iOS. I don't need to receive change notifications, just the current orientation itself. This seems to be a rather simple question, but I ...
71
votes
20
answers
61k
views
AVCaptureVideoPreviewLayer orientation - need landscape
My app is landscape only. I'm presenting the AVCaptureVideoPreviewLayer like this:
self.previewLayer = [[AVCaptureVideoPreviewLayer alloc] initWithSession:session];
[self.previewLayer ...
69
votes
2
answers
2k
views
Odroid-XU4 Android full-screen portrait orientation
I want to install an Android OS to an Odroid-XU4 device and connect it to a vertical touchscreen through HDMI. I want the content be displayed as portrait and fit the screen.
I installed 4.4.4, 6.0 (...
68
votes
4
answers
37k
views
Different ways of getting current interface orientation?
There're 3 ways to get current interface orientation that I know of:
self.interfaceOrientation
[[UIApplication sharedApplication] statusBarOrientation]
[[UIDevice currentDevice] orientation]
What ...
66
votes
17
answers
95k
views
shouldAutorotateToInterfaceOrientation not being called in iOS 6
I'm using MGSplitViewController and I'm usingshouldAutorotateToInterfaceOrientation to control the size of the master view controller on rotation.
It's all working fine on iOS 5 but on iOS 6 (both ...
64
votes
11
answers
51k
views
Get current orientation of iPad?
In a given event handler (not the "shouldAutorotateToInterfaceOrientation" method) how do I detect the current iPad orientation? I have a text field I have to animate up (when keyboard appears) in ...
60
votes
7
answers
52k
views
Setting the orientation for only 1 fragment in my activity while the rest is in portrait
My app needs to be in portrait mode so I set it in the manifest by:
android:screenOrientation="portrait"
But I just recently added another fragment (FragA) that just looks and functions 10x better ...
57
votes
6
answers
75k
views
how to detect orientation of android device?
Is it possible simple to detect current orientation of android device, without programming a listener and handling the position matrix?
In my app I want only to know current orientation - vertical or ...
57
votes
13
answers
71k
views
IOS 6 force device orientation to landscape
I gave an app with say 10 view controllers. I use navigation controller to load/unload them.
All but one are in portrait mode. Suppose the 7th VC is in landscape. I need it to be presented in ...
54
votes
6
answers
103k
views
Detecting iOS orientation change instantly
I have a game in which the orientation of the device affects the state of the game. The user must quickly switch between Landscape, Portrait, and Reverse Landscape orientations. So far I've been ...
54
votes
3
answers
132k
views
Set a border around a StackPanel.
Here's my XAML code:
<Window x:Class="CarFinder.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
...
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 ...
50
votes
10
answers
60k
views
Best way to programmatically detect iPad/iPhone hardware
The reason I need to find out is that on an iPad, a UIPickerView has the same height in landscape orientation as it does in portrait. On an iPhone it is different. The iPad programming guide ...
49
votes
6
answers
75k
views
How can I change the scroll direction in UICollectionView?
I have a UICollectionView in my storyboard based iOS app.
When the device is in the portrait orientation I'd like it to scroll vertically, and when it's in Landscaper I'd like it to scroll ...
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 ...
44
votes
6
answers
44k
views
Orientation in a UIView added to a UIWindow
I have a UIView which is supposed to cover the whole device (UIWindow) to support an image zoom in/out effect I'm doing using core animation where a user taps a button on a UITableViewCell and I zoom ...
43
votes
8
answers
53k
views
Android onConfigurationChanged not being called
I am having trouble with telling Android to not call onCreate() when the orientation changes. I have added android:configChanges="orientation" to my manifest but still when the orientation changes ...
43
votes
5
answers
41k
views
Images taken with ACTION_IMAGE_CAPTURE always returns 1 for ExifInterface.TAG_ORIENTATION on some Gingerbread devices
I had the orientation issue when working with ACTION_IMAGE_CAPTURE activity. I have used the TAG_ORIENTATION so that I would rotate the picture accordingly. But now we found that on some newer devices ...
42
votes
5
answers
20k
views
Save UIImage, Load it in Wrong Orientation
I am using the following code to save and load images that I pick from either the library or take using the camera:
//saving an image
- (void)saveImage:(UIImage*)image:(NSString*)imageName {
...
41
votes
11
answers
67k
views
How can I disable landscape orientation?
I am making an iPhone app and I need it to be in portrait mode, so if the user moves the device sideways, it does not automatically rotate. How can I do this?
41
votes
5
answers
21k
views
Crash on presenting UIImagePickerController under iOS 6.0
My app only supports landscape orientations via the supportedInterfaceOrientation properties.
Using an iOS prior to iOS 6, my app can successfully load an instance of UIImagePickerController via ...
41
votes
10
answers
27k
views
On iOS8, displaying my app in landscape mode will hide the status bar but on iOS 7 the status bar is displayed on both orientations
I want the status bar to be displayed in both orientations in iOS 8; it's being displayed properly in iOS 7.
navigationController.isNavigationBarHidden returns NO.
Why is iOS 8 doing this?
41
votes
7
answers
55k
views
Horizontal UITableView
I want implement a layout in my ipad application that has a uitable view that scrolls left and right rather then up and down :
So rather than
row 1
row 2
row 3
( scrolling vertically )
It would ...
38
votes
13
answers
56k
views
Responsive website on iPhone - unwanted white space on rotate from landscape to portrait
I am creating a responsive website, and have just noticed a strange behaviour in my content pages when viewed on the iPhone. It scales correctly when loaded in portrait mode, and also when rotated to ...