简体   繁体   中英

Android ActivityGroup Screen Orientation

I am facing a serious issue and i cant find any answers for on the internet. In my application i have an activity group which contains four activities. In the activity which extends activity group i haven't specified the screen orientation code fragment,

setRequestedOrientation(1); And in the other 3 activities i have mentioned it to be portrait. And all the activities works fine in portrait mode. But i need one activity to change the orientation when the device rotates. For that activity i havent specified the setRequestedOrientation(1) code. But That activity does not change according to the device rotation.

Has anyone came across an error like this. Any help would be greatly appreciated. Thanks in advance.

In the Android Manifest file, go to Application tab, in that select your activity file. You see the attributes on right side. In that you have the Screen orientation option. There you can set your required orientation.

As you have said, you have ActivityGroup and it contains 4 activities, you are setting Portrait mode to all the activities except one.

Now, I am sure its happening due to your ActivityGroup is having Portrait setting in AndroidManifest file, if you remove then your whole ActivityGroup would be working in both the orientation. If you keep it as Portrait or Landscape then your sub-activities (ie Views) will be in the same orientation as your ActivityGroup has.

the above answer is correct. just add this in your AndroidManifest.xml file in your

android:screenOrientation="portrait" 

for the activities that should be in portrait mode.

for landscape just give as

android:screenOrientation="landscape" 

if you didn't specify anything the application will work in both landscape and portrait modes.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM