您的位置:首页 > 移动开发 > Android开发

Android mainifest 中设置横竖屏

2016-01-22 10:09 513 查看
<activity

android:name=".MaalaPanxi"

android:configChanges="orientation"

android:label="@string/app_name"

android:screenOrientation="landscape"--------------------------------------横屏

android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >

<intent-filter>

<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />

</intent-filter>

</activity>

<activity

android:name="com.acgera.maala.Recharge"

android:configChanges="orientation"

android:label="@string/app_name"

android:screenOrientation="portrait"-----------------------------------竖屏

android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >

</activity>

在开发android的应用中,有时候需要限制横竖屏切换。只需要在AndroidManifest.xml文件中加入android:screenOrientation属性限制。

android:screenOrientation="landscape"是限制此页面横屏显示,

android:screenOrientation="portrait"是限制此页面数竖屏显示。

[html] view plaincopy

android:screenOrientation="landscape"是限制此页面横屏显示,

android:screenOrientation="portrait"是限制此页面数竖屏显示。

android:screenOrientation设定该活动的方向,该值可以是任何一个下面的字符串:

"unspecified"

- 默认值. 由系统选择显示方向. 在不同的设备可能会有所不同.

"landscape"

- 横向

"portrait"

- 纵向

"user"

- 用户当前的首选方向

"behind"

- 与在活动堆栈下的活动相同方向

"sensor"

- 根据物理方向传感器确定方向. 取决於用户手持的方向, 当用户转动设备, 它跟随改变.

"nosensor"

- 不经物理方向传感器确定方向. 该传感器被忽略, 所以当用户转动设备, 显示不会跟随改变. 除了这个区别,系统选择使用相同的政策取向对於“未指定”设置. 系统根据“未指定”("unspecified")设定选择相同显示方向.

如果要使Activity的View界面全屏,只需要将最上面的信号栏和Activity的Title栏隐藏掉即可,隐藏Title栏的代码:

requestWindowFeature(Window.FEATURE_NO_TITLE);

配置文件里代码:

android:theme="@android:style/Theme.NoTitleBar"

隐藏信号栏的代码:

getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);

其它使用:

getWindow().setFlags(WindowManager.LayoutParams.TYPE_STATUS_BAR, WindowManager.LayoutParams.TYPE_STATUS_BAR);
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: