0

I have a problem regarding Android App.
I have created an application that download video from server.
After that it play it on videoview. But the problem is it can't play video on full screen, infact videoview is on set to fill parent.

enter image description here

Please help me regarding that it is very vital for me.

this is my layout image

My layout file...

Community
  • 1
  • 1
Anant
  • 109
  • 2
  • 5
  • 11

2 Answers2

3

VideoView wouldn't try to fill the whole screen of your mobile as it needs to maintain the aspect ratio of the videos. It is important because if you break the aspect ratio, the video would fill stretched and many users wouldn't like it. But if you still want to go full screen , subclass VideoView like :

public class MyVideoView extends VideoView {

        public MyVideoView(Context context) {
            super(context);
        }

        @Override
        protected void onMeasure (int widthMeasureSpec, int heightMeasureSpec)
        {
             setMeasuredDimension(480,800);
        }

    }
Akhil
  • 13,888
  • 7
  • 35
  • 39
  • hi i create a inner class in my activity. but as i run the program it gives an error on following code [**bold**]video = (MyVideoView) findViewById(R.id.surface_view);[**bold**] so i can't run the program – Anant Apr 01 '12 at 07:12
  • you need to add this custom videoview "MyVideoView" replacing your original videoview tag in layout xml . Just replace VideoView keyword with packagename.MyVideoView in your layout xml .For example look at http://stackoverflow.com/questions/6186729/how-to-insert-custom-view-into-xmls-linearlayout – Akhil Apr 01 '12 at 07:16
2

For your VideoView in xml file just add the following attributes

    android:layout_alignParentRight="true"
    android:layout_alignParentLeft="true"
    android:layout_alignParentTop="true"
    android:layout_alignParentBottom="true"

Use this LINK might help you.

Community
  • 1
  • 1
Ishu
  • 5,357
  • 4
  • 16
  • 17
  • android:theme="@android:style/Theme.NoTitleBar.Fullscreen" add this line in manifeat file and also remove android:gravity="center" also try to replace LinearLayout with RelativeLayout – Ishu Apr 01 '12 at 06:08
  • yes i tried the above code its work good on my emulator. but when i install it on my tablet its not working fine... even it is set any corner of my tablet not full screen and if i rotate the tablet video is gone from screen only voice came. – Anant Apr 01 '12 at 07:06