Different Portrait and Landscape layouts with VideoView playing
I have a VideoView taking up the whole screen when in Landscape. I want to be able to constrain the video to the top half of the screen when in portrait so I can show additional controls/info below it.
I'm using "configChanges=orientation" in the manifest to prevent the videoview from restarting when the orientation changes. However this means the different orientation layouts are ignored and only the first one encountered used.
Does anyone have any idea how I would go about keeping the video playing between changes from Portrait开发者_如何转开发 to Landscape and back while in Portrait displaying additional UI components below the video?
Thanks!
You can maintain your data playing in videoview from restarting when orientation takes place:
Override the onRetainNonConfigurationInstance() method to return the object you would like to retain.
When your activity is created again, call getLastNonConfigurationInstance() to recover your object.
you can also refer this doc:
http://developer.android.com/guide/topics/resources/runtime-changes.html
精彩评论