有人尝试制作Camera View for Firebase或通常具有自定义视图。不仅从受支持的视图(例如320x240或1920x480),而且例如从300x900或1000x400
我的相机创建代码:
private void createCameraPreview() {
final int width = componentsOverlayFactory.configHolder.pluginWidth;
final int height = componentsOverlayFactory.configHolder.pluginHeight;
if (preview == null) {
preview = componentsOverlayFactory.initLayout(width, height, this);
GraphicOverlay graphicOverlay = componentsOverlayFactory.getGraphicOverlay();
CameraSourceApi1 cameraSource = componentsOverlayFactory.getCameraSource(getActivity(), this);
try {
CameraSourceApi1Preview apiPreview = (CameraSourceApi1Preview) preview;
apiPreview.start(cameraSource, graphicOverlay);
} catch (IOException e) {
e.printStackTrace();
}
}
if (preview == null) {
// case with not inited mode
return;
}
final int x = componentsOverlayFactory.configHolder.offsetX;
final int y = componentsOverlayFactory.configHolder.offsetY;
view.setOnTouchListener(componentsOverlayFactory.onTouchListener);
FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(width, height);
layoutParams.setMargins(x, y, 0, 0);
frameContainerLayout = (FrameLayout) view.findViewById(getResources().getIdentifier("frame_container", "id", appResourcesPackage));
frameContainerLayout.setLayoutParams(layoutParams);
if (mainLayout == null) {
mainLayout = (FrameLayout) view.findViewById(getResources().getIdentifier("video_view", "id", appResourcesPackage));
mainLayout.setLayoutParams(new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT));
mainLayout.addView(preview);
mainLayout.setEnabled(false);
if (componentsOverlayFactory.configHolder.freezeFunction) {
final Button freezeButton = componentsOverlayFactory.getFreezeButton();
view.addView(freezeButton, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT, Gravity.TOP | Gravity.LEFT));
}
}
}
非常感谢您的帮助