INNER CODE UNIT · Java
onCreate
githubhaohao/NDK_OpenGLES_3_0 · app/src/main/java/com/byteflow/app/MainActivity.java:201
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mRootView = (ViewGroup) findViewById(R.id.rootView);
mRootView.getViewTreeObserver().addOnGlobalLayoutListener(this);
mSensorManager = (SensorManager) getSystemService(SENSOR_SERVICE);
mGLRender.init();
}
@Override
public void onGlobalLayout() {
mRootView.getViewTreeObserver().removeOnGlobalLayoutListener(this);
RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
lp.addRule(RelativeLayout.CENTER_IN_PARENT);
mGLSurfaceView = new MyGLSurfaceView(this, mGLRender);
mRootView.addView(mGLSurfaceView, lp);