1. 代码
public void init() { ViewGroup.LayoutParams framelayout_params = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); mFrameLayout = new FrameLayout(this); mFrameLayout.setLayoutParams(framelayout_params); ViewGroup.LayoutParams edittext_layout_params = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); Cocos2dxEditText edittext = new Cocos2dxEditText(this); edittext.setLayoutParams(edittext_layout_params); mFrameLayout.addView(edittext); mMediaPlayView = new SurfaceView(this); mFrameLayout.addView(mMediaPlayView); mCameraView = new SurfaceView(this); mCameraView.setZOrderOnTop(true); FrameLayout.LayoutParams cameraFL = new FrameLayout.LayoutParams(320, 240,Gravity.TOP); cameraFL.setMargins(900, 50, 0, 0); mCameraView.setLayoutParams(cameraFL); mFrameLayout.addView(mCameraView); this.mGLSurfaceView = this.onCreateView(); mFrameLayout.addView(this.mGLSurfaceView); if (isAndroidEmulator()) this.mGLSurfaceView.setEGLConfigChooser(8, 8, 8, 8, 16, 0); this.mGLSurfaceView.setEGLConfigChooser(8 , 8, 8, 8, 16, 0); this.mGLSurfaceView.getHolder().setFormat(PixelFormat.TRANSLUCENT); this.mGLSurfaceView.setZOrderOnTop(true); this.mGLSurfaceView.setCocos2dxRenderer(new Cocos2dxRenderer()); this.mGLSurfaceView.setCocos2dxEditText(edittext); setContentView(mFrameLayout); }
2. 效果图