力作用方向查看 [英] Force orientation to view
问题描述
我只是一个活动的三个不同的看法。这三个视图存储在三个不同的XML文件。
I have three different views for just one activity. These three views are stored in three different xml files.
我知道这可能迫使活动定向code的这一部分:
I know it's possible to force activities orientation with this part of code :
<activity
android:screenOrientation="portrait"
</activity>
不过,我想对第一种观点纵向,并在另外两个横向。我怎样才能做到这一点?
But I'd like to have portrait orientation on the first view, and landscape orientation on the two others. How can I achieve this?
推荐答案
您可以看看setRequestedOrientation(INT)。只是把它设置你的看法了。
You could take a look at setRequestedOrientation(int). Just call it after you set your view.
的http://developer.android.com/reference/android/app/Activity.html#setRequestedOrientation(int)
您可能想看看添加机器人:configChanges =方向,这让我们的Android知道你正在服用的方向变化照顾自己
You might want to look at adding android:configChanges="orientation", which let's Android know you are taking care of the orientation changes yourself.
这篇关于力作用方向查看的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!