android之横屏、全屏
1.设置全屏
在Activity的onCreate方法中的setContentView(myview)调用之前添加下面代码,可实现全屏
requestWindowFeature(Window.FEATURE_NO_TITLE);//隐藏标题栏
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);//设置全屏
2.设置横屏
两种方式:
1.重写onResume()方法
protected void onResume() {
if(getRequestedOrientation()!=ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE){
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE)//设置横屏
}
//SCREEN_ORIENTATION_PORTRAIT此参数为设置为竖屏
super.onResume();
}
2.修改配置文件AndroidManifest.xml
在配置文件中对Activity节点添加android:screenOrientation属性(landscape是横向,portrait是纵向)
android:launchMode="singleTask" android:screenOrientation="portrait">