Questions tagged [android-orientation]

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

The orientation of the screen can be locked in place by specifying it in the , or it can change dynamically based on the user's actions.

Useful links

873 questions
1051
votes
31 answers

How can I disable landscape mode in Android?

How can I disable landscape mode for some of the views in my Android app?
lostInTransit
  • 70,519
  • 61
  • 198
  • 274
302
votes
14 answers

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 orientation changes on other phones as well). But I…
Vidar Vestnes
  • 42,644
  • 28
  • 86
  • 100
236
votes
8 answers

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 - I want to dismiss the progess dialog and start…
fhucho
  • 34,062
  • 40
  • 136
  • 186
158
votes
16 answers

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 would like know how is it possible hard code an…
hap497
  • 154,439
  • 43
  • 83
  • 99
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
109
votes
9 answers

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 way to retain data in TextView too?
88
votes
2 answers

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(savedInstanceState); …
user1811741
  • 883
  • 1
  • 7
  • 5
80
votes
7 answers

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
  • 11,776
  • 16
  • 70
  • 126
70
votes
9 answers

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 rotates the phone/tablet. I've read about…
60
votes
9 answers

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() method, but doesn't work. Then I've found this post…
beni
  • 3,019
  • 5
  • 35
  • 55
50
votes
11 answers

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 one in landscape which provides a full screen…
Mark G.
  • 3,176
  • 1
  • 27
  • 29
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
4 answers

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 i am getting the the expected exif orientation…
hacker
  • 8,919
  • 12
  • 62
  • 108
36
votes
11 answers

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 tried all the answers from StackOverflow and nothing…
insomniac
  • 11,146
  • 6
  • 44
  • 55
33
votes
7 answers

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 layout, the other three do not and need to be fixed to…
1
2 3
58 59