安卓:景观儿童活动在人像选项卡活动 [英] Android: Landscape Child Activity in a Portrait Tab Activity
问题描述
我有三个孩子的活动,A,B和C.儿童活动A和B的标签活动都遵循标签活动的方向。即如果卡活动是在纵向应该如此A和B,如果标签活动是景观也应该A和B
I have a tab activity that has three child activities, A, B and C. Child activities A and B are to follow the orientation of the tab activity. i.e. if the tab activity is in portrait so should A and B, if the tag activity is landscape so should A and B.
儿童活动C必须始终处于横向无论标签的活动方向(preferably以下的android:screenOrientation =sensorLandscape)。这可能吗?
Child activity C should always be in landscape orientation regardless of the tab activity orientation (preferably following android:screenOrientation="sensorLandscape"). Is this possible?
我已经采用了android尝试:在清单screenOrientation =sensorLandscape对于C不工作。我可以管理的最好是使用在C以下(在onResume())
I have tried using android:screenOrientation="sensorLandscape" for C in the manifest which doesn't work. The best I can manage is to use the following in C (in onResume())
this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
和A和B我使用(也onResume())
and for A and B I use (also in onResume())
this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
但这种翻转整个标签这是不是我要找的效果。
But this flips the entire tab which is not the effect I'm looking for.
任何帮助是AP preciated。问候。
Any help is appreciated. Regards.
推荐答案
我面临同样的问题。不知道如果这是一个很好的解决方案,但我发现了解决方法如下:
把 this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
在的setContentView()
中的onCreate( )
活动C.方法并把 this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
在的setContentView()
另外两个活动(A和B)。
I faced the same problem. Dont know if it is a good solution, but the workaround I found is as follows:
Put this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
before the setContentView()
of onCreate()
method of Activity C. And put this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
before the setContentView()
of onCreate()
method of other two Activities (A and B).
任何其他的解决方案是非常AP preciated。
Any other elegant solution is highly appreciated.
这篇关于安卓:景观儿童活动在人像选项卡活动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!