1

I have a VideoView which resizes on keyboard events. I observed that the video (played by VideoView) will not resize even though the VideoView's layout is changed (the changes are clearly visible). Is there any call I need to make to resize the video to the new layout?

I have tried 'invalidate()' and 'requestLayout()', but they did not work.

Dunes Buggy
  • 1,779
  • 1
  • 21
  • 41

3 Answers3

3

You need to create a custom VideoView since it require to invoke these 2 methods :

onMeasure() and onConfigurationChanged()

this Answer has explained in very deep detail, please check below:

Android VideoView orientation change with buffered video

Community
  • 1
  • 1
Sruit A.Suk
  • 7,073
  • 7
  • 61
  • 71
3

I managed to re-actualize my VideoView size by doing this after changing it's owner Layout:

mVideoView.getHolder().setSizeFromLayout();
J.Jacobs
  • 703
  • 6
  • 17
  • This Worked for me. First i called invalidate() on the most parent ViewGroup that contained the VideoView and then called getHolder().setSizeFromLayout() on the VideoView – PrashanD Mar 24 '17 at 11:26
-1

Use FrameLayout as parent of videoView

 <?xml version="1.0" encoding="utf-8"?>
 <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
   android:layout_width="fill_parent"
   android:layout_height="fill_parent">

   <VideoView
       android:id="@+id/myVideo"
       android:layout_width="match_parent"
       android:layout_height="match_parent"
       android:layout_gravity="center" />

</FrameLayout>
Suneesh Ambatt
  • 1,347
  • 1
  • 11
  • 41