I created a video presentation in my activity, when the action begins, I want to change the height and length of the video. How to do it?
This is my code. I tried with simple layout options and a frame, nothing works for me
final VideoView vvVideos = (VideoView) rootView.findViewById(R.id.videoView); MediaController mediacontroller = new MediaController(ctx); mediacontroller.setAnchorView(vvVideos); String videoFileName = videos.get(position); Uri video = Uri.parse("android.resource://" + packageName +"/"+R.raw.sample); vvVideos.setMediaController(mediacontroller); //LayoutParams lp = new LayoutParams(LayoutParams.MATCH_PARENT,150); vvVideos.setLayoutParams(new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT,150)); vvVideos.setVideoURI(video); vvVideos.requestFocus(); vvVideos.setOnPreparedListener(new OnPreparedListener() { // Close the progress bar and play the video public void onPrepared(MediaPlayer mp) { //pDialog.dismiss(); vvVideos.start(); } });
Decision
This code works for me ....
LayoutParams params=vvVideos.getLayoutParams(); params.height=150; vvVideos.setLayoutParams(params);
source share