@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // 设置为全屏 requestWindowFeature(Window.FEATURE_NO_TITLE); getWindow() .setFlags( WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); // 获得系统的宽度以及高度 DisplayMetrics dm = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(dm); if (dm.widthPixels > dm.heightPixels) { WIDTH = dm.widthPixels; HEIGHT = dm.heightPixels; } else { WIDTH = dm.heightPixels; HEIGHT = dm.widthPixels; } // 设置为横屏模式 setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); mview = new MySurfaceView(this); mview.requestFocus(); // 获取焦点 mview.setFocusableInTouchMode(true); // 设置为可触控 setContentView(mview); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // 设置为全屏 requestWindowFeature(Window.FEATURE_NO_TITLE); getWindow() .setFlags( WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); // 设置为横屏模式 setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); // 初始化GLSurfaceView mGLSurfaceView = new MySurfaceView(this); setContentView(mGLSurfaceView); mGLSurfaceView.requestFocus(); // 获取焦点 mGLSurfaceView.setFocusableInTouchMode(true); // 设置为可触控 }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); getWindow() .setFlags( WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); MV = new MySurfaceView(this); setContentView(MV); MV.requestFocus(); MV.setFocusableInTouchMode(true); cameraView = new CameraView(this); addContentView( cameraView, new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); }