尝试从父视图充气并添加具有特定宽度和高度的自定义视图。我尝试使用布局参数,手动设置SurfaceView大小等等,但是没有运气。在此方面停留了一段时间,不胜感激。
父视图的高度和宽度正确:
我尝试用XML布局扩大视图并以编程方式调用它。我猜想它必须与父母做些事情。父级是RelativeLayout视图,我也尝试过Frame和Coordinator视图。如果父母全屏显示,那意味着孩子没有房间了吗?我该如何解决,以使多个具有相同大小的视图堆叠?
if (mainVideoView == null) {
mainVideoView = new VideoView(themedReactContext);
addView(mainVideoView, new LayoutParams(getWidth(), getHeight()));
addOnTapListener(mainVideoView);
}
看一下布局检查器,我可以看到布局的高度和宽度已经设置好了,但是实际的视图高度和宽度却没有设置。
public void init() {
createAudioTrack();
if (mode != null && role != null) {
if (role.equals(ROLE_PRESENTER)) {
switch (mode) {
case MODE_VIDEO:
addOnTapListener(mainVideoView);
createVideoTrack(null);
break;
case MODE_AR:
inflate(getContext(), R.layout.ar_layout, this);
arView = findViewById(R.id.ar_container);
arView.setBackgroundColor(Color.GREEN);
arView.setLayoutParams(new FrameLayout.LayoutParams(getWidth(), getHeight(), Gravity.CENTER));
arView.setMinimumWidth(getWidth());
arView.setMinimumHeight(getHeight());
arView.measure(MeasureSpec.makeMeasureSpec(
getWidth(), MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(
getHeight(), MeasureSpec.EXACTLY));
arView.requestLayout();
requestLayout();
createVideoTrack(new ViewCapturer(arView.arFragment.getArSceneView()));
break;
case MODE_MEASURE:
createVideoTrack(null);
break;
default:
break;
}
}
}
}
ViewGroup“ TwilioVideo”的日志显示正确的大小:
I/@@@TwilioVideo: resume
I/@@@TwilioVideo: twilio video focus: true
I/@@@TwilioVideo: visibiity: 6
I/@@@TwilioVideo: AR PRESENTER
I/@@@TwilioVideo: 2220 1080
I/@@@ARView: onFinishInflate
I/@@@Format: 0 0 30
I/@@@Format: 0 0 30
I/@@@Format: 0 0 30
I/@@@Format: 0 0 30