Questions tagged [android-orientation]

The orientation of the screen, i.e. landscape (wider than tall) or portrait (taller than wide)

android-orientation
Filter by
Sorted by
Tagged with
1058 votes
32 answers
706k views

How can I disable landscape mode in Android?

How can I disable landscape mode for some of the views in my Android app?
lostInTransit's user avatar
303 votes
15 answers
258k views

How do I disable orientation change on Android?

I have an application that I just would like to use in portrait mode, so I have defined android:screenOrientation="portrait" in the manifest XML. This works OK for the HTC Magic phone (and prevents ...
Vidar Vestnes's user avatar
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 ...
fhucho's user avatar
  • 34.3k
161 votes
16 answers
334k views

Force an Android activity to always use landscape mode

I am using the Android VNC viewer on my HTC G1. But for some reason, that application is always in landscape mode despite my G1 is in portrait mode. Since the Android VNC viewer is open source, I ...
hap497's user avatar
  • 159k
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-...
Christopher Perry's user avatar
109 votes
9 answers
67k views

Restoring state of TextView after screen rotation?

In my app I have TextView and EditText. Both have data in it. When the screen orientation changes the data in the EditText remains, but TextView data is cleared. Can some one help me out to find a ...
kAnNaN's user avatar
  • 3,669
88 votes
2 answers
88k views

Fool-proof way to handle Fragment on orientation change

public class MainActivity extends Activity implements MainMenuFragment.OnMainMenuItemSelectedListener { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(...
user1811741's user avatar
81 votes
7 answers
91k views

How to fix layout orientation to vertical?

How to fix layout orientation to portrait and do not allow changing from portrait to landscape during run time?
Harinder's user avatar
  • 11.8k
71 votes
9 answers
72k views

Changing number of columns with GridLayoutManager and RecyclerView

Inside my fragment I'm setting my GridLayout in the following way: mRecycler.setLayoutManager(new GridLayoutManager(rootView.getContext(), 2)); So, I just want to change that 2 for a 4 when the user ...
fapps's user avatar
  • 1,819
60 votes
9 answers
61k views

Controlling the camera to take pictures in portrait doesn't rotate the final images

I'm trying to controlling the Android camera to take pictures in a portrait app, but when I save the picture, it's in landscape. I've rotated the image 90 grades with setCameraDisplayOrientation() ...
beni's user avatar
  • 3,029
50 votes
11 answers
67k views

Android VideoView orientation change with buffered video

I'm trying to replicate the functionality of the latest YouTube app in the Android marketplace. When watching a video there's two separate layouts, one in portrait which provides additional info, and ...
Mark G.'s user avatar
  • 3,206
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 ...
moorka's user avatar
  • 563
41 votes
4 answers
31k views

EXIF orientation tag value always 0 for image taken with portrait camera app android

I have a camera app in portrait mode which takes pictures from both front and back end cameras.I am saving the image in my sd card and try to find the corresponding exif value which gives 0 always.But ...
hacker's user avatar
  • 8,949
36 votes
11 answers
27k views

Android emulator not rotating to landscape

When i try to switch the orientation of my emulator, the emulator window rotates and the orientation of the emulator screen stays as it were. Can anyone tell me what is the reason for this?I have ...
insomniac's user avatar
  • 11.5k
33 votes
7 answers
32k views

Allow rotation/landscape in one fragment

My app has a single Activity with a FragmentPagerAdapter with four fragments (Using the ViewPagerIndicator library). One of these fragments has designs for both a separate portrait and landscape ...
Garcon's user avatar
  • 2,513
27 votes
4 answers
25k views

What's the conceptual difference between rotation vector sensor and orientation sensor in Android?

Android provides both the rotation vector sensor and the orientation sensor. I know they returns different data, because for vector sensor we have sin of angles, in orientation sensor we have angles. ...
user1781028's user avatar
  • 1,498
24 votes
1 answer
5k views

how i can break things with Fragments with setRetainInstance(true) and adding them to backstack?

the docs on setRetainInstance say : This can only be used with fragments not in the back stack. so I started playing with it. I have one Activity with adds first frag A FragmentManager fm = ...
AndroidGecko's user avatar
  • 14.1k
23 votes
7 answers
10k views

Activity orientation changes automatically on Android

I'm developing a mobile application based on Android with minSdkVersion=15. I would like to support both orientations for tablets and only portrait for smartphones. Everything works like a charm but I'...
JJack_'s user avatar
  • 869
21 votes
2 answers
10k views

Android emulator camera - webcam orientation

I am using my Mac webcam to simulate an Android front-camera in the emulator. Unfortunately the camera seems in landscape orientation - screenshot, even though the emulator is in portrait one. Note ...
Ohad Navon's user avatar
  • 1,703
20 votes
6 answers
60k views

Android - switching between landscape and portrait mode makes Intent lose values

I am using Intents to switch between activities in my Android app. I am putting data in the Intent for use in the next activity. When I switch the phone between landscape and portrait modes, the ...
lostInTransit's user avatar
20 votes
1 answer
3k views

How automatic fragment restore works

When using FragmentActivity it automatically restores fragment state and recreates all fragments. I know this is done mainly saving the state in onSaveInstanceState and then restored in activity's ...
lujop's user avatar
  • 13.7k
19 votes
1 answer
10k views

What is the difference between screenOrientation portrait and userPortrait

I need know the real difference of screen orientation userPortrait and portrait. When to use what? When this? android:screenOrientation="portrait" When this? android:screenOrientation="...
Libin's user avatar
  • 17k
19 votes
3 answers
20k views

Set orientation to landscape in android on both sides [duplicate]

I am working in an android application in 2.2 and I want to set my application in landscape mode. For that I added in my manifest with every activity tag android:screenOrientation="landscape" and ...
Arun PS's user avatar
  • 4,640
18 votes
2 answers
13k views

Retaining list in list fragment on orientation change

I have an app using fragments, all of which are contained in a single activity. The activity starts with a fragment containing a menu of buttons, all of which cause various listfragments to replace ...
Barak's user avatar
  • 16.3k
18 votes
2 answers
15k views

How to rotate views on orientation change without recreating layout?

This question has been asked before here but its answer is incorrect. I would like to rotate some views on screen orientation change, but I want to keep the layout unchanged. They should be rotated 90,...
Hussein El Feky's user avatar
17 votes
7 answers
36k views

OpenCV camera orientation issue

I have a simple project that just show the camera with org.opencv.android.JavaCameraView. my problem is that in default the camera is on landscape mode and I can't change this cause I need to define ...
user2235615's user avatar
  • 1,513
17 votes
4 answers
25k views

Android Fragments recreated on orientation change

I'm developing an app that basically has an ActionBar. When my app starts, the Activity creates the fragments and attaches them to each tab, so when I switch I get different views. The problems arise ...
Luke47's user avatar
  • 1,583
17 votes
2 answers
21k views

How do I preserve the state of a selected spinner/dropdown item on orientation change?

I am using a spinner dropdown in my code , in which I have 4 to 5 dynamically populated values, say if I have "apples" set to default and I select "oranges" from the dropdown and rotate my screen to ...
user avatar
17 votes
2 answers
14k views

How to lock fragment orientation without locking activity orientation?

I have a specific use case where I want a fragment to be locked in portrait mode, but still rotate the activity (and/or other fragments visible in the same activity). Is it possible to do that? All ...
Kathy's user avatar
  • 263
16 votes
6 answers
15k views

Android CameraX image rotated

I have followed Google CameraX code lab to implement custom camera. Camera preview is fine but when i take image after image capture image is rotated. I am taking image in portrait mode but saved ...
Nouman Bhatti's user avatar
15 votes
3 answers
26k views

Android orientation change calls onCreate

I've made a search screen that has one tab for keywords, filters, and a search button, and three optional tabs for the different types of results (each containing a ListView with an ArrayAdapter). ...
Samah's user avatar
  • 1,224
15 votes
1 answer
7k views

Best Way: Save & Restore TextView Position in ScrollView

What i want is, upon the device changes orientation, the top line on the screen when in Portrait remains the top line on screen in Landscape. And vice versa. As the width of the screen is likely to ...
midnite's user avatar
  • 5,216
14 votes
3 answers
11k views

Camera capture orientation on samsung devices in android

I am creating a camera app. The image when captured is shown in the grid view. Now, the code is working completely fine on all the devices except for samsung devices. I am facing the orientation ...
android developer's user avatar
14 votes
1 answer
2k views

YouTubePlayerSupportFragment in a single-Activity app with orientation change

I tried to solve this problem, searched through the Internet, no real answer was found. I'm developing an app where the YouTube player is needed. This player is the YouTubePlayerSupportFragment since ...
Gergely Kőrössy's user avatar
13 votes
4 answers
13k views

SCREEN_ORIENTATION_LANDSCAPE upside down - Why?

I am using the following code to set orientation locking per user preference: private void doLock(boolean locked) { if (locked) { int o = getResources().getConfiguration().orientation; ...
an00b's user avatar
  • 11.4k
13 votes
2 answers
11k views

android fragment created twice on orientation change

i am having this weird problem where my list fragment is created twice, once when the super.oncreate is called on the parent activity and once when the setContentView is called on the same parent ...
Pishtewan Agha's user avatar
13 votes
2 answers
4k views

How to manage UI state and the back stack in a single/dual-pane layout

I'm having trouble wrapping my head around how to properly manage Fragments in a typical list-detail design pattern. My layout is working fine and is structured like this for the landscape view (dual ...
quietmint's user avatar
  • 14k
12 votes
2 answers
29k views

prevent activity restarting when orientation changes

I am new to android development .I have separate screens for portrait and landscape mode.When i change my orientation corresponding screen gets loaded and activity restarts . Now i do not want my ...
sujay's user avatar
  • 1,845
11 votes
3 answers
4k views

Change orientation at runtime

I'm new to android my question is, Is it possible to change orientation programmatically? If yes, how can we do that?
jayellos's user avatar
  • 691
11 votes
5 answers
4k views

How EditText Retains its value but not textview when phone orientation changes?

What is so special about Edittext that it can retain the value but not Textview and some other widgets and we have to use onSavedInstance() method for them. What is the magic behind EditText ...
Hisham Muneer's user avatar
11 votes
1 answer
4k views

Detecting if video was taken in portrait/landscape

I would like to confirm that what I am doing is indeed the correct way as some elements behave unexpected. First, I have a landscape and portrait layout, as I understand, doing this will ...
ClassA's user avatar
  • 2,550
11 votes
1 answer
15k views

Why does onLayout and onSizeChanged get called twice on an orientation change?

I've noticed that onLayout and onSizeChanged get called twice in immediate succession after an orientation change, either from landscape->portrait or from portrait->landscape, when handling the ...
MikeV's user avatar
  • 1,221
10 votes
3 answers
2k views

ActionBar in PreferenceFragment not recalculating height and font size

Using the latest AppCompat-v21 library, I used ActionBarActivity to create and populate the PreferenceFragment. However, the ActionBar does not seem to change height and the text size when the ...
jyoonPro's user avatar
  • 1,661
9 votes
1 answer
2k views

Activity rotating itself and back to normal in android 8.1

My App is running fine for all the android version but I have noticed that in Android 8.1.0 (Oreo) when I go the screen from portrait activity to landscape activity and when I press back button it ...
Ahmad Arslan's user avatar
  • 4,528
9 votes
1 answer
5k views

android:screenOrientation=“sensorPortrait" not valid?

I need to limit my app to displaying in portrait mode. Using android:screenOrientation=“Portrait" works great but I'd like to have the display change to reverse portrait when the device is rotated. ...
Rob 'user1478730''s user avatar
9 votes
4 answers
22k views

Disable and enable orientation changes in an activity in Android programatically

I have an App that make some background staff. When the background work is running a progress Circle is shown, if the device is rotated during this time then the Activity is "reset" and I want to ...
Ivan BASART's user avatar
9 votes
2 answers
7k views

Rotating phone quickly 180 degrees, camera preview turns upside down

I have a custom camera application. When I rotating the phone by 90, camera preview works fine. But when I rotate phone quickly 180 degree, camera preview turns upside down. Is there any solution... ...
Mohammad Rajob's user avatar
9 votes
2 answers
10k views

Setting Android Photo EXIF Orientation

I have written an Android activity that captures a photo programatically. I want to save the image as a JPEG with the correct EXIF orientation data (just like the native Android Camera app does ...
Joshua W's user avatar
  • 4,973
9 votes
3 answers
5k views

Restore WebView position to same content on orientation change (Android)

I am facing an issue with WebView content scroll position and here it is: I am scolling down the page to some extent in portrait mode and when I change orientation to landscape the scroll moves up or ...
Lavanya's user avatar
  • 3,913
9 votes
1 answer
14k views

Android: Get current device orientation [duplicate]

I have the activity orientation in manifest set as portrait. As i dont want my screen to rotate. But On Clicking a button, I want to get the current device orientation (portrait or landscape) in ...
Kushal's user avatar
  • 131

1
2 3 4 5
18