简体   繁体   English

Android ActivityGroup 屏幕方向

[英]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.在其他 3 个活动中,我提到它是肖像。 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.对于那个活动,我没有指定 setRequestedOrientation(1) 代码。 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.在 Android Manifest 文件中,go 到 Application 选项卡中,在 select 您的活动文件中。 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.正如您所说,您有ActivityGroup并且它包含 4 个活动,您正在将纵向模式设置为除一个之外的所有活动。

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.现在,我确信它的发生是因为您的ActivityGroupAndroidManifest文件中有 Portrait 设置,如果您删除,那么您的整个ActivityGroup将在两个方向上工作。 If you keep it as Portrait or Landscape then your sub-activities (ie Views) will be in the same orientation as your ActivityGroup has.如果您将其保持为纵向或横向,那么您的子活动(即视图)将与您的ActivityGroup的方向相同。

the above answer is correct.上面的答案是正确的。 just add this in your AndroidManifest.xml file in your只需将其添加到您的 AndroidManifest.xml 文件中

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.如果您没有指定任何内容,应用程序将在横向和纵向模式下工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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