0

Now I am working on an Android application. In my app I have to play a video in the corner of the screen.I just play the video using videoview.

 Uri uri =       Uri.parse(path);
    MediaController mc = new MediaController(this);
    videoView.setMediaController(mc);
    videoView.setVideoURI(uri);
    videoView.start();

My requirment is I have to expand the video in to full screen when clicking on the expand button like IPhone.ANd we have to collapse in to the old screen by clicking collapse button. In IPhone it is a default property. How can I achieve that in android?

For example..first time I am showing the video in a layout with other views . Then If I click the expand button on videoview I have see the video in full screen also I can collpse back to the original screen.

My doubts are. 1) add expand button to the videoview 2) change size of the videoview from fixed size to fullscreen

bytecode77
  • 14,163
  • 30
  • 110
  • 141
sarath
  • 3,181
  • 7
  • 36
  • 58

1 Answers1

1

There you go :

VideoView view_instance = (VideoView)findViewById(R.id.nutrition_bar_filled);
LayoutParams params=view_instance.getLayoutParams();
params.width=newOne;
params.height=newOne;
view_instance.setLayoutParams(params);

referenced from here

Community
  • 1
  • 1
Jibran Khan
  • 3,236
  • 4
  • 37
  • 50
  • Edited my question. please check – sarath May 08 '13 at 11:36
  • Yes you need to set the video view height and width to match_parent so the control will take full screen if it is directly placed on the parent layout. – Jibran Khan May 08 '13 at 11:50
  • @JibranKhan how will i define width and height if my videoview parent is inside relativelayout – Erum Sep 16 '15 at 12:27
  • @Erum you will have to apply `setLayoutParams` to parent and parent's parent also if you want to alter their width height as well – Jibran Khan Sep 16 '15 at 12:44
  • @JibranKhan http://pastie.org/10423424 here is my layout file ? what should i need to add code but my min api level is 16 so i cant follow this question ?and how can i add another layout if my orientation is horizontal ? – Erum Sep 16 '15 at 12:49
  • @Erum what you actually want to achieve ? – Jibran Khan Sep 16 '15 at 12:55
  • @Erum so you actually need to make it fullscreen on landscape and compress it on portrait ? – Jibran Khan Sep 16 '15 at 14:44
  • Yes how will I do @Jibran khan – Erum Sep 16 '15 at 16:28
  • @Erum You can change width and height of the video or its relative layout by listening to orientation change event http://stackoverflow.com/questions/5726657/how-to-detect-orientation-change-in-layout-in-android – Jibran Khan Sep 16 '15 at 16:40
  • answer above will do it after you successfully listen to orientation change – Jibran Khan Sep 16 '15 at 16:41
  • @JibranKhan actually i have made custom layout for portrait and in portait i have viewpager and tabs below videoview now i lancape i dnt want viewpager but more buttons on top of video that is not present in portrait mode so mayi need to inflate anotehr layout for lanscape once orentation change ? – Erum Sep 17 '15 at 04:30