getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);//设置成全屏模式
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);//强制为横屏
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);//竖屏

在activity里设置android:screenOrientation的值。
android:screenOrientation的属性有以下值:
unspecified(默认值,由系统判断状态自动切换),The default value. The system chooses the orientation. The policy it uses, and therefore the choices made in specific contexts, may differ from device to device.
landscape,横屏
portrait,竖屏
user(用户当前设置的orientation值),The user's current preferred orientation.
behind(下一个要显示的Activity的orientation值),The same orientation as the activity that's immediately beneath it in the activity stack.
sensor(传感器的方向),The orientation determined by a physical orientation sensor. The orientation of the display depends on how the user is holding the device; it changes when the user rotates the device.
nosensor(不使用传感器,这个效果差不多等于unspecified).An orientation determined without reference to a physical orientation sensor. The sensor is ignored, so the display will not rotate based on how the user moves the device. Except for this distinction, the system chooses the orientation using the same policy as for the "unspecified" setting.

Android设置横屏竖屏的更多相关文章

  1. Android 设置 横屏 竖屏 (转)

    http://2960629.blog.51cto.com/2950629/701227 方法一:在AndroidManifest.xml中配置 如果不想让软件在横竖屏之间切换,最简单的办法就是在项目 ...

  2. Android 设置 横屏 竖屏

    方法一:在AndroidManifest.xml中配置 如果不想让软件在横竖屏之间切换,最简单的办法就是在项目的AndroidManifest.xml中找到你所指定的activity中加上androi ...

  3. 【转】Android 模拟器横屏竖屏切换设置

    http://blog.csdn.net/zanfeng/article/details/18355305# Android 模拟器横屏竖屏切换设置时间:2012-07-04   来源:设计与开发   ...

  4. Android之横屏竖屏显示问题

    1.採用不同的布局文件 在res下创建目录layout-land 在该目录下写入的layout(xml文件)横屏的时候系统自己主动选择显示的layout 同理: 在res下创建目录layout-por ...

  5. Android之设置横屏竖屏

    方案一:在AndroidManifest.xml中配置 在项目的AndroidManifest.xml中找到你所指定的activity中加上Android:screenOrientation属性,它有 ...

  6. Android判断横屏竖屏代码

    // 判断Android当前的屏幕是横屏还是竖屏.横竖屏判断 if (this.getResources().getConfiguration().orientation == Configurati ...

  7. Android禁止横屏竖屏切换

    在Android中要让一个程序的界面始终保持一个方向,不随手机方向转动而变化的办法: 只要在AndroidManifest.xml里面配置一下就可以了. 在AndroidManifest.xml的ac ...

  8. cocos2d-x ios 设置横屏/竖屏(全)

    Cocos2d-x项目\iOS\RootViewController.mm文件中. 以下方法任选其一即可…      本人机子函数二ok! 函数一: (BOOL)shouldAutorotateToI ...

  9. Android横屏竖屏切换的问题

    Android横屏竖屏切换的问题 http://blog.sina.com.cn/s/blog_77c632410101790w.html

随机推荐

  1. SpringMVC小结

    一放下就生疏,所以要温故,所以要笔记. Tip,多数情况下,SpringMVC建议单例执行,Struts2建议多例执行. 原因就在于Struts2使用属性驱动或模型驱动,而SpringMVC则使用方法 ...

  2. Asp.net WebApi下载文件

    1,图片 var result = new HttpResponseMessage(HttpStatusCode.OK) { Content = new ByteArrayContent(stream ...

  3. C#绘制数字图像灰度直方图

    灰度直方图是灰度的函数,描述的是图像中具有该灰度级的像素的个数.如果用直角坐标系来表示,则它的横坐标是灰度级,纵坐标是该灰度出现的概率(像素的个数). 灰度直方图的分布函数: 其中,K是指第k个灰度级 ...

  4. Xianfeng轻量级Java中间件平台:属性管理、字典管理

    属性管理:主要功能是维护一些系统定义的.业务定义的属性数据,至于属性是什么,简单的说就是由键key和值value组成的数据,属性查询列表页面如下: 表格实现了直接编辑的功能 字典管理:主要功能是维护一 ...

  5. systemd的运行级别与服务管理命令简介

    从很久很久以前我们就在使用静态运行级别.而systemd提供了更为动态灵活的机制,来管控你的系统. 在开始介绍systemd命令前,让我们先简单的回顾一下历史.在Linux世界里,有一个很奇怪的现象, ...

  6. MyBatis通用Mapper技巧

    一.排序 错误代码:example.orderBy(BaseEntity.Field.GMTUpdate + " desc"); 正确方式: 一是:通过注解 @OrderBy(va ...

  7. Jenkins使用简易教程

    Jenkins是一款能提高效率的软件,它能帮你把软件开发过程形成工作流,典型的工作流包括以下几个步骤 开发 提交 编译 测试 发布 有了Jenkins的帮助,在这5步中,除了第1步,后续的4步都是自动 ...

  8. Yii2查询之where条件拼装

    目录 1 语法 2 哈希格式 3 运算符格式 3.1 对比 3.2 and 3.3 or 3.4 not 3.5 between和not between 3.6 in和not in 3.7 like ...

  9. 使用go,基于martini,和websocket开发简易聊天室

    一.首先,需要了解一下websocket基本原理:here 二.go语言的websocket实现: 基于go语言的websocket也有不少,比如github.com/gorilla/websocke ...

  10. 安卓开发笔记——关于AsyncTask的使用

    在安卓开发中,我们经常要进行一些耗时操作,比如数据库操作,获取网络资源,读取内存文件等等,当我们在处理这些耗时操作的时候,如果我们直接在UI主线程进行,那么可能会导致阻塞UI主线程,使得UI界面卡顿, ...