指定纵向和反向纵向模式的布局

时间:2012-01-13 10:26:06

标签: android android-layout

有没有办法为纵向模式指定一种布局而另一种为纵向反转模式?

通过纵向模式,我的意思是您旋转设备,例如,向右(从横向模式)和反向纵向模式 - 向左旋转。

所以,我的观点是制作右侧菜单,它总是在那里(按钮只会旋转)。或者有更好的解决方案来实现这一目标吗?

2 个答案:

答案 0 :(得分:3)

您需要使用以下代码手动执行此操作:

protected void onConfigurationChanged(Configuration newConfig) {
int currentOrientation = getResources().getConfiguration().orientation;
if(newConfig.orientation == ActivityInfo.SCREEN_ORIENTATION_PORTRAIT ||
    newConfig.orientation == ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT) {
    super.onConfigurationChanged(newConfig);
} }

Activity in portrait or reverse portrait only

中所述

答案 1 :(得分:-1)

创建文件夹layout-land和layout-port

您可以在此处找到更多信息:

http://developer.android.com/guide/practices/screens_support.html