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. JDK源码阅读之Collection

    源码版本:JDK 1.7. 集合 Collection,根据已知的内容可以知道有List.Set.Map(严格说,Map不属于Collection)等大类. 先查看 Collection, publi ...

  2. 多线程系列八:线程安全、Java内存模型(JMM)、底层实现原理

    一.线程安全 1.  怎样让多线程下的类安全起来 无状态.加锁.让类不可变.栈封闭.安全的发布对象 2. 死锁 2.1 死锁概念及解决死锁的原则 一定发生在多个线程争夺多个资源里的情况下,发生的原因是 ...

  3. (转)Android分布式编译学习(一)distcc实现分布式编译 —— Ubuntu12.04上部署distcc分布式编译

    转自:http://blog.csdn.net/eqiang8271/article/details/17144411   版权声明:本文为博主原创文章,未经博主允许不得转载. Android代码庞大 ...

  4. ASP.NET后台输出js脚本代码

    利用asp.net输出js我们大多数都会直接使用Respone.Write()然后根js格式的代码,再在页面调用时我们直接这样是完全可以实现的,下面我来给大家介绍另一种方法 我是我最初的想法以下是代码 ...

  5. linux 系统安装配置 zabbix服务(源码安装)

    简介: zabbix是一个基于WEB界面的提供分布式系统监视以及网络监视功能的企业级的开源解决方案. zabbix能监视各种网络参数,保证服务器系统的安全运营:并提供灵活的通知机制以让系统管理员快速定 ...

  6. SecureCRT同时发送命令到所有主机

    有时候我们需要在多台服务器上执行相同的命令,比如安装软件,复制,粘贴,删除等等,但一台一台的去操作工作量就太大了,我们可以借助SecureCRT这款客户端远程连接工具实现这样的要求! 相关阅读: 如何 ...

  7. Android立刻终止一个线程

    /** * Created by JuTao on 2017/2/4. * 如何中止一个线程 */ public class ThreadDone { public static void main( ...

  8. C#:添加web service引用

    VS2012里是这样添加web service引用的:

  9. php把数组、字符串 生成文件

    生成的代码 data/ss.php <?php return array ( ', ', ); php代码 $str = "<?php\nreturn \n"; $my ...

  10. 【Linux】理解分区

    http://blog.csdn.net/aaronychen/article/details/2270048 主分区逻辑分区设置 http://forum.ubuntu.org.cn/viewtop ...