0

I want to implement a video player using video view in android. Everything is working from functionality point of view. But there is a problem with full screen mode and orientation change. I want video view in such way that, In Landscape mode full screen video should be played and in portrait mode it should be positioned at center with Width as Fill_parent and Height as Wrap_content. So is there any solution for that?

Suresh
  • 7,785
  • 1
  • 16
  • 28

1 Answers1

1

Sure, you can create two diff layouts for two different orientations. Then you can dynamically assign the particular layout on orientation change. Like this:

    public void onCreate(Bundle savedInstanceState)
        {

            //opening particular layout
            super.onCreate(savedInstanceState);
            //checking whether orientation is portrait or landscape
            if (getResources().getConfiguration().orientation == 1)
            {

    setContentView(R.layout.main_portrait);
                }

else if(getResources().getConfiguration().orientation == 2)
        {
setContentView(R.layout.main_land);
            }

Then you may design both the layouts differently according to your requirements.

kittu88
  • 2,451
  • 5
  • 40
  • 80
  • After changing orientation it stops video and a black screen appear. – Suresh Nov 20 '12 at 13:26
  • Actually your activity is getting refreshed on orientation change. To stop that please follow this link http://stackoverflow.com/a/5913370/1627599 – kittu88 Nov 21 '12 at 04:26
  • Instead of doing setContentView in orientation change. Make a seprate folder with name as layout-land and paste the layout for landscape mode in that. it will automatically handle that. – Suresh Nov 21 '12 at 11:21