Android VideoView resizing won't resize video

3.4k views Asked by At

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.

3

There are 3 answers

0
Sruit A.Suk On

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

0
Suneesh Ambatt On

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>
1
J.Jacobs On

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

mVideoView.getHolder().setSizeFromLayout();