this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
getWindow().setFormat(PixelFormat.TRANSLUCENT);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
1、有关android中横屏和竖屏的值: 在某些场合可能需要禁止横屏和竖屏切换,实现这个要求很简单,只要在AndroidManifest.xml里面加入这一行
@Override
} catch (Exception ex) {
}
}
2、getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);//设置成全屏模式
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE););//强制为横屏
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);//竖屏
requestWindowFeature(Window.FEATURE_NO_TITLE);//去掉标题栏
设置屏幕显示模式ScreenOrientation.
在activity里设置android:screenOrientation的值。
android:screenOrientation的属性有以下值:
- unspecified(默 认值,由系统判断状态自动切换)
- landscape,横屏
- portrait,竖屏
- user(用户当前设置的orientation值)
- behind(下一个要显示的Activity的orientation值)
- sensor(传 感器的方向)
- nosensor(不 使用传感器,这个效果差不多等于unspecified).
获得当前屏幕宽高的方法.
Display display = getWindowManager().getDefaultDisplay();
Config.screenWidth = display.getWidth();//宽度
Config.screenHeight = display.getHeight()//;高度