开发者

Different Portrait and Landscape layouts with VideoView playing

开发者 https://www.devze.com 2023-04-01 00:48 出处:网络
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 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:

  1. Override the onRetainNonConfigurationInstance() method to return the object you would like to retain.

  2. 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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号