Code example for SurfaceView

Methods: getLayoutParamssetClickablesetLayoutParams

0
		int screenHeight = getWindowManager().getDefaultDisplay().getHeight();
		float screenProportion = (float) screenWidth / (float) screenHeight;
		Log.i(TAG, "VIDEO SIZES: W: " + screenWidth + " H: " + screenHeight + " PROP: " + screenProportion);
 
		// Get the SurfaceView layout parameters 
		android.view.ViewGroup.LayoutParams lp = surfaceViewFrame.getLayoutParams();
 
		if (videoProportion > screenProportion) {
			lp.width = screenWidth;
			lp.height = (int) ((float) screenWidth / videoProportion);
		} else { 
			lp.width = (int) (videoProportion * (float) screenHeight);
			lp.height = screenHeight;
		} 
 
		// Commit the layout parameters 
		surfaceViewFrame.setLayoutParams(lp);
 
		// Start video 
		if (!player.isPlaying()) {
			player.start();
			updateMediaProgress(); 
			linearLayoutMediaController.setVisibility(View.VISIBLE);
			hideMediaController(); 
		} 
		surfaceViewFrame.setClickable(true);
	} 
 
	public void onCompletion(MediaPlayer mp) {
		mp.stop();
		if (updateTimer != null) {