我得调查一下
VideoFragment
想办法解决这个问题。
视频片段
有一个简单的
SurfaceView
作为其布局的根元素,您所要做的就是
表面视图
匹配父级(即设备屏幕)的宽度和高度。这样做只是超越
onVideoSizeChanged
getSurfaceView
获取对包private的引用
表面视图
中使用的实例
视频片段
.
@Override
protected void onVideoSizeChanged(int width, int height) {
switch (scaleMode) {
//Flag indicates that this video should stretch to screen
case MediaMetaData.SCALE_MODE_STRETCH:
View rootView = getView();
SurfaceView surfaceView = getSurfaceView();
ViewGroup.LayoutParams params = surfaceView.getLayoutParams();
params.height = rootView.getHeight();
params.width = rootView.getWidth();
surfaceView.setLayoutParams(params);
break;
//When the video shouldn't stretch, just invoke super to have the VideoFragment's default behavior which is fit to screen
default:
super.onVideoSizeChanged(width, height);
}
}