横屏方法
1. 在AndroidManifest.xml中的Activity加入android:screenOrientation="landscape"
配置文件中对Activity节点添加android:screenOrientation属性(landscape是横向,portrait是纵向)
<activity android:name=".TestActivity" android:screenOrientation="landscape"                   android:label="@string/app_name">            <intent-filter>                <action android:name="android.intent.action.MAIN" />                <category android:name="android.intent.category.LAUNCHER" />            </intent-filter>        </activity>


2. 在Java的Activity中写入以下方法:
要设置成竖屏设置成 SCREEN_ORIENTATION_PORTRAIT
@Overrideprotected void onResume() {if (getRequestedOrientation() != ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE) {setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);}super.onResume();}


全屏方法
public void onCreate(Bundle savedInstanceState) {        super.onCreate(savedInstanceState);             //设置全屏显示         requestWindowFeature(Window.FEATURE_NO_TITLE);        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,                WindowManager.LayoutParams.FLAG_FULLSCREEN);        setContentView(R.layout.main);}



保持背景灯常亮
public void onCreate(Bundle savedInstanceState) {        super.onCreate(savedInstanceState);    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);        setContentView(R.layout.main);}

更多相关文章

  1. Android中一个Activity多个intent-filter的调用方法
  2. 关于android SDK安装Failed to fetch URL http://dl-ssl.google.
  3. 【 Android(安卓)'四大组件' 】篇 -- Activity 的 "启动流程"
  4. android scroller类的使用
  5. vue.js的h5页面与android(WebViewJavascriptBridge) / ios(windo
  6. Android开发进阶:如何读写Android文件
  7. Unity与Android的互相调用
  8. Android(安卓)面试必备 - JVM 及 类加载机制
  9. Android(安卓)Launcher 分析

随机推荐

  1. adb connect 失败时(unable to connect t
  2. Android(安卓)从网页中跳转到APP
  3. android 结束进程
  4. android view视图的层叠(叠加)
  5. android intent
  6. 一:android开发简介
  7. Android应用开发相关下载资源(2016/07/24
  8. Android(安卓)5.0以上Button,ImageView自
  9. 演化理解 Android(安卓)异步加载图片
  10. activity的android:name 设置问题