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);
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);
相关文章推荐
- Android开发笔记--屏蔽返回键,home键以及其他实体按键
- 如何处理Android Studio 上面关于 update 和 commit 小箭头的消失
- Android开发笔记--Back键 生命周期
- android studio for mac Cannot run program Permission denied
- Android开发笔记--捕获Home键
- android 虚拟导航挡住应用底部解决方案(屏幕底部的三个按键)
- Android View刷新机制
- Android开发笔记--调用短信,电话,E-Mail,浏览器
- Android开发笔记--制作启动界面splash
- Android开发笔记--Dialog提示框
- Android开发笔记--操纵字符串中的字符
- Android开发笔记--按钮添加事件的四种方法
- Android开发笔记--隐藏按钮
- Android 瘦身攻略
- Android Icons下载使用
- Android-利用LinearGradient实现文字一闪一闪
- Android无需root实现apk的静默安装
- Android中使用Gson解析JSON数据
- 简析Android的垃圾回收与内存泄露
- Android万能适配器